-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang] Add handlers for 'match_any' and 'match_all' to
gpuintrin.h
(…
…#127504) Summary: These helpers are very useful but currently absent. They allow the user to get a bitmask representing the matches within the warp. I have made an executive decision to drop the `predicate` return from `match_all` because it's easily testable with `match_all() == __activemask()`.
- Loading branch information
Showing
5 changed files
with
182 additions
and
0 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
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,35 @@ | ||
//===-- Test for the shuffle operations on the GPU ------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "src/__support/CPP/bit.h" | ||
#include "src/__support/GPU/utils.h" | ||
#include "test/IntegrationTest/test.h" | ||
|
||
using namespace LIBC_NAMESPACE; | ||
|
||
// Test to ensure that match any / match all work. | ||
static void test_match() { | ||
uint64_t mask = gpu::get_lane_mask(); | ||
EXPECT_EQ(1ull << gpu::get_lane_id(), | ||
gpu::match_any(mask, gpu::get_lane_id())); | ||
EXPECT_EQ(mask, gpu::match_any(mask, 1)); | ||
|
||
uint64_t expected = gpu::get_lane_id() < 16 ? 0xffff : 0xffff0000; | ||
EXPECT_EQ(expected, gpu::match_any(mask, gpu::get_lane_id() < 16)); | ||
EXPECT_EQ(mask, gpu::match_all(mask, 1)); | ||
EXPECT_EQ(0ull, gpu::match_all(mask, gpu::get_lane_id())); | ||
} | ||
|
||
TEST_MAIN(int argc, char **argv, char **envp) { | ||
if (gpu::get_thread_id() >= gpu::get_lane_size()) | ||
return 0; | ||
|
||
test_match(); | ||
|
||
return 0; | ||
} |