Skip to content

Commit 79253cf

Browse files
authored
[libc] Fix integration tests on w64 amdgpu targets (#152303)
Summary: We need `malloc` to return a larger size now that it's aligned properly and we use a bunch of threads. Also the `match_any` test was wrong because it assumed a 32-bit lanemask.
1 parent 0d7c869 commit 79253cf

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

libc/test/IntegrationTest/test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ int atexit(void (*func)(void)) { return LIBC_NAMESPACE::atexit(func); }
6363
// which just hands out continuous blocks from a statically allocated chunk of
6464
// memory.
6565

66-
static constexpr uint64_t ALIGNMENT = alignof(long double);
67-
static constexpr uint64_t MEMORY_SIZE = 65336;
66+
static constexpr uint64_t ALIGNMENT = alignof(double);
67+
static constexpr uint64_t MEMORY_SIZE = 256 * 1024 /* 256 KiB */;
6868
alignas(ALIGNMENT) static uint8_t memory[MEMORY_SIZE];
6969
static size_t ptr = 0;
7070

@@ -75,7 +75,7 @@ void *malloc(size_t size) {
7575
size = (size + ALIGNMENT - 1) & ~(ALIGNMENT - 1);
7676
size_t old_ptr =
7777
ref.fetch_add(size, LIBC_NAMESPACE::cpp::MemoryOrder::RELAXED);
78-
if (static_cast<size_t>(old_ptr + size) > MEMORY_SIZE)
78+
if (static_cast<size_t>(old_ptr + size) >= MEMORY_SIZE)
7979
return nullptr;
8080
return &memory[old_ptr];
8181
}

libc/test/integration/src/__support/GPU/match.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ static void test_match() {
2121
gpu::match_any(mask, gpu::get_lane_id()));
2222
EXPECT_EQ(mask, gpu::match_any(mask, 1));
2323

24-
uint64_t expected = gpu::get_lane_id() < 16 ? 0xffff : 0xffff0000;
24+
uint64_t full_mask =
25+
gpu::get_lane_size() > 32 ? 0xffffffffffffffff : 0xffffffff;
26+
uint64_t expected = gpu::get_lane_id() < 16 ? 0xffff : full_mask & ~0xffff;
2527
EXPECT_EQ(expected, gpu::match_any(mask, gpu::get_lane_id() < 16));
2628
EXPECT_EQ(mask, gpu::match_all(mask, 1));
2729
EXPECT_EQ(0ull, gpu::match_all(mask, gpu::get_lane_id()));

0 commit comments

Comments
 (0)