mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
redesign for faster cpu/gpu synch (#1869)
* redesign for faster cpu/gpu synch * load + more async CPU * use command encoder API and move more ops to use it * make fence back-end generic + CPU only fence * faster build * fix async eval * fixes + handle temporaries * fix / improve cpu conv * remove unused status, fix siblings * fix extensions * fix * fix no cpu build * format * comments * fix perf regression, remove unecessary abort * fix events, task limit cpu * fix waiting * fix donation / temporaries in normalization
This commit is contained in:
17
mlx/event.h
17
mlx/event.h
@@ -10,9 +10,8 @@ namespace mlx::core {
|
||||
|
||||
class Event {
|
||||
public:
|
||||
Event() = default;
|
||||
|
||||
Event(const Stream& steam);
|
||||
Event() {};
|
||||
explicit Event(Stream stream);
|
||||
|
||||
// Wait for the event to be signaled at its current value
|
||||
void wait();
|
||||
@@ -20,6 +19,12 @@ class Event {
|
||||
// Signal the event at its current value
|
||||
void signal();
|
||||
|
||||
// Wait in the given stream for the event to be signaled at its current value
|
||||
void wait(Stream stream);
|
||||
|
||||
// Signal the event at its current value in the given stream
|
||||
void signal(Stream stream);
|
||||
|
||||
// Check if the event has been signaled at its current value
|
||||
bool is_signaled() const;
|
||||
|
||||
@@ -44,15 +49,11 @@ class Event {
|
||||
return stream_;
|
||||
}
|
||||
|
||||
const std::shared_ptr<void>& raw_event() const {
|
||||
return event_;
|
||||
}
|
||||
|
||||
private:
|
||||
// Default constructed stream should never be used
|
||||
// since the event is not yet valid
|
||||
Stream stream_{0, Device::cpu};
|
||||
std::shared_ptr<void> event_;
|
||||
std::shared_ptr<void> event_{nullptr};
|
||||
uint64_t value_{0};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user