mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-01 21:04:41 +08:00
Add synchronize function (#1006)
* add synchronize function * fix linux * fix linux * fix and fix docs * fix test * try synchronize in stream destroy * synchronize works for both cpu and gpu
This commit is contained in:
@@ -495,16 +495,16 @@ TEST_CASE("test metal memory info") {
|
||||
|
||||
// Query active and peak memory
|
||||
{
|
||||
// Do these tests on the CPU since deallocation is synchronized
|
||||
// with the main thread.
|
||||
auto a = zeros({4096}, Device::cpu);
|
||||
auto a = zeros({4096});
|
||||
eval(a);
|
||||
synchronize();
|
||||
auto active_mem = metal::get_active_memory();
|
||||
CHECK(active_mem >= 4096 * 4);
|
||||
{
|
||||
auto b = zeros({4096}, Device::cpu);
|
||||
auto b = zeros({4096});
|
||||
eval(b);
|
||||
}
|
||||
synchronize();
|
||||
auto new_active_mem = metal::get_active_memory();
|
||||
CHECK_EQ(new_active_mem, active_mem);
|
||||
auto peak_mem = metal::get_peak_memory();
|
||||
|
Reference in New Issue
Block a user