Skip to content

Commit 3d99a8d

Browse files
authored
Fix format / build (#489)
1 parent a749a91 commit 3d99a8d

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

mlx/backend/no_metal/metal.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ std::function<void()> make_task(
1919
"[metal::make_task] Cannot make GPU task without metal backend");
2020
}
2121

22+
// No cache for CPU only
23+
bool cache_enabled(void) {
24+
return false;
25+
}
26+
void set_cache_enabled(bool) {}
27+
2228
} // namespace mlx::core::metal

tests/metal_tests.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#include <array>
44
#include "doctest/doctest.h"
55

6+
#include "mlx/backend/metal/allocator.h"
67
#include "mlx/backend/metal/device.h"
78
#include "mlx/backend/metal/metal.h"
8-
#include "mlx/backend/metal/allocator.h"
99
#include "mlx/mlx.h"
1010

1111
using namespace mlx::core;
@@ -479,36 +479,37 @@ TEST_CASE("test metal enable/disable cache") {
479479
metal::set_cache_enabled(true);
480480
CHECK(metal::cache_enabled());
481481

482-
auto &a = metal::allocator();
482+
auto& a = metal::allocator();
483483
auto size = 100;
484484
auto buf = a.malloc(size, false);
485-
485+
486486
// Release a
487487
a.free(buf);
488-
488+
489489
// Check size should equals to size
490490
CHECK_EQ(static_cast<MTL::Buffer*>(buf.ptr())->length(), size);
491491
}
492-
492+
493493
// Test disable metal cache
494494
{
495495
metal::set_cache_enabled(false);
496496
CHECK(!metal::cache_enabled());
497497

498-
auto &a = metal::allocator();
498+
auto& a = metal::allocator();
499499
auto size = 100;
500500
auto buf = a.malloc(size, false);
501501
auto buf_ptr = static_cast<MTL::Buffer*>(buf.ptr());
502502
unsigned char first_byte = *reinterpret_cast<unsigned char*>(buf_ptr);
503503
printf("first byte: %d\n", first_byte);
504-
504+
505505
// Release a
506506
a.free(buf);
507-
508-
// If release successfully, the first byte should be different from the first byte before release
507+
508+
// If release successfully, the first byte should be different from the
509+
// first byte before release
509510
unsigned char new_first_byte = *reinterpret_cast<unsigned char*>(buf_ptr);
510511
printf("new first byte: %d\n", new_first_byte);
511-
512+
512513
CHECK_NE(new_first_byte, first_byte);
513514
}
514515
}

0 commit comments

Comments
 (0)