forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMP][OMPX] Add ballot_sync (llvm#91297)
This patch adds the support for `ballot_sync` in ompx.
- Loading branch information
Showing
5 changed files
with
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// RUN: %libomptarget-compilexx-run-and-check-generic | ||
// | ||
// UNSUPPORTED: x86_64-pc-linux-gnu | ||
// UNSUPPORTED: x86_64-pc-linux-gnu-LTO | ||
// UNSUPPORTED: aarch64-unknown-linux-gnu | ||
// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO | ||
// UNSUPPORTED: s390x-ibm-linux-gnu | ||
// UNSUPPORTED: s390x-ibm-linux-gnu-LTO | ||
|
||
#if defined __AMDGCN_WAVEFRONT_SIZE && __AMDGCN_WAVEFRONT_SIZE == 64 | ||
#define MASK 0xaaaaaaaaaaaaaaaa | ||
#else | ||
#define MASK 0xaaaaaaaa | ||
#endif | ||
|
||
#include <assert.h> | ||
#include <ompx.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main(int argc, char *argv[]) { | ||
const int num_blocks = 1; | ||
const int block_size = 256; | ||
const int N = num_blocks * block_size; | ||
uint64_t *data = (uint64_t *)malloc(N * sizeof(uint64_t)); | ||
|
||
for (int i = 0; i < N; ++i) | ||
data[i] = i & 0x1; | ||
|
||
#pragma omp target teams ompx_bare num_teams(num_blocks) thread_limit(block_size) map(tofrom: data[0:N]) | ||
{ | ||
int tid = ompx_thread_id_x(); | ||
uint64_t mask = ompx_ballot_sync(~0U, data[tid]); | ||
data[tid] += mask; | ||
} | ||
|
||
for (int i = 0; i < N; ++i) | ||
assert(data[i] == ((i & 0x1) + MASK)); | ||
|
||
// CHECK: PASS | ||
printf("PASS\n"); | ||
|
||
return 0; | ||
} |
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