-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
152 changed files
with
4,053 additions
and
1,659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#ifndef ARK_ERROR_HPP_ | ||
#define ARK_ERROR_HPP_ | ||
|
||
#include <stdexcept> | ||
#include <string> | ||
|
||
namespace ark { | ||
|
||
#define REGISTER_ERROR_TYPE(_name) \ | ||
class _name : public std::runtime_error { \ | ||
public: \ | ||
_name(const std::string &msg) : std::runtime_error(msg) {} \ | ||
}; | ||
|
||
REGISTER_ERROR_TYPE(InvalidUsageError) | ||
REGISTER_ERROR_TYPE(ModelError) | ||
REGISTER_ERROR_TYPE(SchedulerError) | ||
REGISTER_ERROR_TYPE(ExecutorError) | ||
REGISTER_ERROR_TYPE(SystemError) | ||
REGISTER_ERROR_TYPE(GpuError) | ||
REGISTER_ERROR_TYPE(RuntimeError) | ||
REGISTER_ERROR_TYPE(UnitTestError) | ||
|
||
} // namespace ark | ||
|
||
#endif // ARK_ERROR_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "ark/executor.hpp" | ||
|
||
#include <algorithm> | ||
#include <memory> | ||
#include <string> | ||
|
||
#include "env.h" | ||
#include "gpu/gpu_loop_kernel.h" | ||
#include "logging.h" | ||
#include "sched/sched.h" | ||
|
||
namespace ark { | ||
|
||
class Executor::Impl { | ||
public: | ||
Impl(int rank, int world_size, const Model &model, const Schedule &schedule, const std::string &name, | ||
int num_warps_per_sm); | ||
~Impl() = default; | ||
|
||
void compile(); | ||
void launch(); | ||
void run(int iter); | ||
void wait(); | ||
float stop(); | ||
|
||
private: | ||
const int rank_; | ||
const int world_size_; | ||
int gpu_id_; | ||
|
||
std::shared_ptr<GpuContext> ctx_; | ||
std::unique_ptr<GpuLoopKernel> glk_; | ||
std::shared_ptr<GpuStream> stream_; | ||
}; | ||
|
||
Executor::Impl::Impl(int rank, int world_size, const Model &model, const Schedule &schedule, | ||
const std::string &name, int num_warps_per_sm) | ||
: rank_(rank), world_size_(world_size) { | ||
gpu_id_ = rank_ % get_env().num_ranks_per_host; | ||
sched_.reset(static_cast<BaseScheduler *>(new DefaultScheduler{ | ||
model, gpu_id_, rank_, world_size_, num_warps_per_sm})); | ||
|
||
ctx_ = sched_->create_context(); | ||
const GpuManager::Info &ginfo = ctx_->get_gpu_manager()->info(); | ||
stream_ = ctx_->get_gpu_manager()->create_stream(); | ||
glk_ = std::make_unique<GpuLoopKernel>( | ||
ctx_, name, sched_->gen_code(), ginfo.num_sm, num_warps_per_sm, | ||
(unsigned int)ginfo.smem_block_total); | ||
} | ||
|
||
void Executor::Impl::compile() { glk_->compile(); } | ||
|
||
void Executor::Impl::launch() { | ||
glk_->load(); | ||
glk_->launch(stream_, false); | ||
} | ||
|
||
void Executor::Impl::run(int iter) { glk_->run(iter); } | ||
|
||
void Executor::Impl::wait() { glk_->wait(); } | ||
|
||
float Executor::Impl::stop() { | ||
glk_->stop(); | ||
return glk_->get_elapsed_msec(); | ||
} | ||
|
||
Executor::Executor(int rank, int world_size, const Model &model, const Schedule &schedule, | ||
const std::string &name, int num_warps_per_sm) | ||
: impl_{std::make_unique<Executor::Impl>(rank, world_size, model, schedule, name, | ||
num_warps_per_sm)} {} | ||
|
||
Executor::~Executor() = default; | ||
|
||
void Executor::compile() { impl_->compile(); } | ||
|
||
void Executor::launch() { impl_->launch(); } | ||
|
||
void Executor::run(int iter) { impl_->run(iter); } | ||
|
||
void Executor::wait() { impl_->wait(); } | ||
|
||
float Executor::stop() { return impl_->stop(); } | ||
|
||
} // namespace ark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.