-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* wip * NCCLThread * use NCCLThread in LinearExecutor * cleanup * rm * remove order_group
- Loading branch information
Showing
15 changed files
with
138 additions
and
395 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
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,33 @@ | ||
#pragma once | ||
#include <condition_variable> | ||
#include <mutex> | ||
#include <queue> | ||
|
||
namespace kungfu | ||
{ | ||
template <typename T> | ||
class MpscChannel // unbound multiple producer single consumer channel | ||
{ | ||
std::mutex mu_; | ||
std::queue<T> buffer_; | ||
|
||
std::condition_variable cv_; | ||
|
||
public: | ||
T get() | ||
{ | ||
std::unique_lock<std::mutex> lk(mu_); | ||
cv_.wait(lk, [&]() { return buffer_.size() > 0; }); | ||
const T x = buffer_.front(); | ||
buffer_.pop(); | ||
return x; | ||
} | ||
|
||
void put(T x) | ||
{ | ||
std::unique_lock<std::mutex> lk(mu_); | ||
buffer_.push(x); | ||
cv_.notify_one(); | ||
} | ||
}; | ||
} // namespace kungfu |
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 @@ | ||
#pragma once | ||
#include <condition_variable> | ||
#include <mutex> | ||
|
||
namespace kungfu | ||
{ | ||
class Waiter | ||
{ | ||
std::mutex mu; | ||
std::condition_variable cv; | ||
bool _done; | ||
|
||
public: | ||
Waiter() : _done(false) {} | ||
|
||
void done() | ||
{ | ||
std::lock_guard<std::mutex> lk(mu); | ||
_done = true; | ||
cv.notify_one(); | ||
} | ||
|
||
void wait() | ||
{ | ||
std::unique_lock<std::mutex> lk(mu); | ||
cv.wait(lk, [this] { return this->_done; }); | ||
} | ||
}; | ||
} // namespace kungfu |
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 |
---|---|---|
@@ -1,27 +1,4 @@ | ||
#include <kungfu.h> | ||
#include <libkungfu-comm.h> | ||
|
||
order_group_t *new_ranked_order_group(int n_names) | ||
{ | ||
order_group_t *og = new order_group_t; | ||
GoNewOrderGroup(GoInt(n_names), og); | ||
return og; | ||
} | ||
|
||
void del_order_group(order_group_t *og) | ||
{ | ||
GoFreeOrderGroup(og); | ||
delete og; | ||
} | ||
|
||
void order_group_do_rank(order_group_t *og, int rank, callback_t *task) | ||
{ | ||
GoOrderGroupDoRank(og, rank, task); | ||
} | ||
|
||
void order_group_wait(order_group_t *og, int32_t *arrive_order) | ||
{ | ||
GoOrderGroupWait(og, arrive_order); | ||
} | ||
|
||
void kungfu_run_main() { GoKungfuRunMain(); } |
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
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.