mirror of
https://github.com/siemens-mobile-hacks/llvm-c166.git
synced 2026-11-25 21:45:57 +00:00
Until now, strict behavior in the number of threads and blocks has been applied only when the kernel is in bare mode. When this mode is enabled, the values passed in UserNumBlocks and UserThreadLimit are not adjusted and are the definitive values used to launch the kernel. This commit detaches the strictness from the kernel mode. This is going to be used by the kernel replay tool. Additionally, it starts clearing the path for the upcoming OpenMP dims modifier, used to configure multidimensional teams and leagues, which will include strictness choices for teams and threads. All the bare kernels must indicate strict behavior. Asserts are added to check this condition.
153 lines
6.2 KiB
C
153 lines
6.2 KiB
C
// RUN: %libomptarget-compile-generic
|
|
// RUN: env LIBOMPTARGET_INFO=63 %libomptarget-run-generic 2>&1 | \
|
|
// RUN: %fcheck-generic
|
|
//
|
|
// REQUIRES: gpu
|
|
|
|
#include <ompx.h>
|
|
#include <stdio.h>
|
|
|
|
void get_gridsizes(int *nblocks, int *nthreads) {
|
|
if (ompx_block_id_x() == 0 && ompx_thread_id_x() == 0 &&
|
|
ompx_block_id_y() == 0 && ompx_thread_id_y() == 0 &&
|
|
ompx_block_id_z() == 0 && ompx_thread_id_z() == 0) {
|
|
nblocks[0] = ompx_grid_dim_x();
|
|
nblocks[1] = ompx_grid_dim_y();
|
|
nblocks[2] = ompx_grid_dim_z();
|
|
nthreads[0] = ompx_block_dim_x();
|
|
nthreads[1] = ompx_block_dim_y();
|
|
nthreads[2] = ompx_block_dim_z();
|
|
}
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
int nblocks[3], nthreads[3];
|
|
|
|
// CHECK: PluginInterface device 0 info: Launching kernel
|
|
// CHECK-SAME: __omp_offloading_{{.*}} with [64,1,1] blocks and [32,1,1]
|
|
// CHECK-SAME: threads in BARE mode
|
|
nblocks[0] = nblocks[1] = nblocks[2] = nthreads[0] = nthreads[1] =
|
|
nthreads[2] = 0;
|
|
#pragma omp target teams ompx_bare num_teams(64) thread_limit(32) \
|
|
map(tofrom : nblocks, nthreads)
|
|
{
|
|
get_gridsizes(nblocks, nthreads);
|
|
}
|
|
// CHECK: nblocks: 64 1 1, nthreads: 32 1 1
|
|
fprintf(stderr, "nblocks: %d %d %d, nthreads: %d %d %d\n", nblocks[0],
|
|
nblocks[1], nblocks[2], nthreads[0], nthreads[1], nthreads[2]);
|
|
|
|
// CHECK: PluginInterface device 0 info: Launching kernel
|
|
// CHECK-SAME: __omp_offloading_{{.*}} with [64,1,1] blocks and [32,4,1]
|
|
// CHECK-SAME: threads in BARE mode
|
|
nblocks[0] = nblocks[1] = nblocks[2] = nthreads[0] = nthreads[1] =
|
|
nthreads[2] = 0;
|
|
#pragma omp target teams ompx_bare num_teams(64) thread_limit(32, 4) \
|
|
map(tofrom : nblocks, nthreads)
|
|
{
|
|
get_gridsizes(nblocks, nthreads);
|
|
}
|
|
// CHECK: nblocks: 64 1 1, nthreads: 32 4 1
|
|
fprintf(stderr, "nblocks: %d %d %d, nthreads: %d %d %d\n", nblocks[0],
|
|
nblocks[1], nblocks[2], nthreads[0], nthreads[1], nthreads[2]);
|
|
|
|
// CHECK: PluginInterface device 0 info: Launching kernel
|
|
// CHECK-SAME: __omp_offloading_{{.*}} with [64,1,1] blocks and [32,4,2]
|
|
// CHECK-SAME: threads in BARE mode
|
|
nblocks[0] = nblocks[1] = nblocks[2] = nthreads[0] = nthreads[1] =
|
|
nthreads[2] = 0;
|
|
#pragma omp target teams ompx_bare num_teams(64) thread_limit(32, 4, 2) \
|
|
map(tofrom : nblocks, nthreads)
|
|
{
|
|
get_gridsizes(nblocks, nthreads);
|
|
}
|
|
// CHECK: nblocks: 64 1 1, nthreads: 32 4 2
|
|
fprintf(stderr, "nblocks: %d %d %d, nthreads: %d %d %d\n", nblocks[0],
|
|
nblocks[1], nblocks[2], nthreads[0], nthreads[1], nthreads[2]);
|
|
|
|
// CHECK: PluginInterface device 0 info: Launching kernel
|
|
// CHECK-SAME: __omp_offloading_{{.*}} with [64,16,1] blocks and [32,1,1]
|
|
// CHECK-SAME: threads in BARE mode
|
|
nblocks[0] = nblocks[1] = nblocks[2] = nthreads[0] = nthreads[1] =
|
|
nthreads[2] = 0;
|
|
#pragma omp target teams ompx_bare num_teams(64, 16, 1) thread_limit(32) \
|
|
map(tofrom : nblocks, nthreads)
|
|
{
|
|
get_gridsizes(nblocks, nthreads);
|
|
}
|
|
// CHECK: nblocks: 64 16 1, nthreads: 32 1 1
|
|
fprintf(stderr, "nblocks: %d %d %d, nthreads: %d %d %d\n", nblocks[0],
|
|
nblocks[1], nblocks[2], nthreads[0], nthreads[1], nthreads[2]);
|
|
|
|
// CHECK: PluginInterface device 0 info: Launching kernel
|
|
// CHECK-SAME: __omp_offloading_{{.*}} with [64,16,1] blocks and [32,4,1]
|
|
// CHECK-SAME: threads in BARE mode
|
|
nblocks[0] = nblocks[1] = nblocks[2] = nthreads[0] = nthreads[1] =
|
|
nthreads[2] = 0;
|
|
#pragma omp target teams ompx_bare num_teams(64, 16, 1) thread_limit(32, 4) \
|
|
map(tofrom : nblocks, nthreads)
|
|
{
|
|
get_gridsizes(nblocks, nthreads);
|
|
}
|
|
// CHECK: nblocks: 64 16 1, nthreads: 32 4 1
|
|
fprintf(stderr, "nblocks: %d %d %d, nthreads: %d %d %d\n", nblocks[0],
|
|
nblocks[1], nblocks[2], nthreads[0], nthreads[1], nthreads[2]);
|
|
|
|
// CHECK: PluginInterface device 0 info: Launching kernel
|
|
// CHECK-SAME: __omp_offloading_{{.*}} with [64,16,1] blocks and [32,4,2]
|
|
// CHECK-SAME: threads in BARE mode
|
|
nblocks[0] = nblocks[1] = nblocks[2] = nthreads[0] = nthreads[1] =
|
|
nthreads[2] = 0;
|
|
#pragma omp target teams ompx_bare num_teams(64, 16, 1) thread_limit(32, 4, 2) \
|
|
map(tofrom : nblocks, nthreads)
|
|
{
|
|
get_gridsizes(nblocks, nthreads);
|
|
}
|
|
// CHECK: nblocks: 64 16 1, nthreads: 32 4 2
|
|
fprintf(stderr, "nblocks: %d %d %d, nthreads: %d %d %d\n", nblocks[0],
|
|
nblocks[1], nblocks[2], nthreads[0], nthreads[1], nthreads[2]);
|
|
|
|
// CHECK: PluginInterface device 0 info: Launching kernel
|
|
// CHECK-SAME: __omp_offloading_{{.*}} with [64,16,8] blocks and [32,1,1]
|
|
// CHECK-SAME: threads in BARE mode
|
|
nblocks[0] = nblocks[1] = nblocks[2] = nthreads[0] = nthreads[1] =
|
|
nthreads[2] = 0;
|
|
#pragma omp target teams ompx_bare num_teams(64, 16, 8) thread_limit(32) \
|
|
map(tofrom : nblocks, nthreads)
|
|
{
|
|
get_gridsizes(nblocks, nthreads);
|
|
}
|
|
// CHECK: nblocks: 64 16 8, nthreads: 32 1 1
|
|
fprintf(stderr, "nblocks: %d %d %d, nthreads: %d %d %d\n", nblocks[0],
|
|
nblocks[1], nblocks[2], nthreads[0], nthreads[1], nthreads[2]);
|
|
|
|
// CHECK: PluginInterface device 0 info: Launching kernel
|
|
// CHECK-SAME: __omp_offloading_{{.*}} with [64,16,8] blocks and [32,4,1]
|
|
// CHECK-SAME: threads in BARE mode
|
|
nblocks[0] = nblocks[1] = nblocks[2] = nthreads[0] = nthreads[1] =
|
|
nthreads[2] = 0;
|
|
#pragma omp target teams ompx_bare num_teams(64, 16, 8) thread_limit(32, 4) \
|
|
map(tofrom : nblocks, nthreads)
|
|
{
|
|
get_gridsizes(nblocks, nthreads);
|
|
}
|
|
// CHECK: nblocks: 64 16 8, nthreads: 32 4 1
|
|
fprintf(stderr, "nblocks: %d %d %d, nthreads: %d %d %d\n", nblocks[0],
|
|
nblocks[1], nblocks[2], nthreads[0], nthreads[1], nthreads[2]);
|
|
|
|
// CHECK: PluginInterface device 0 info: Launching kernel
|
|
// CHECK-SAME: __omp_offloading_{{.*}} with [64,16,8] blocks and [32,4,2]
|
|
// CHECK-SAME: threads in BARE mode
|
|
nblocks[0] = nblocks[1] = nblocks[2] = nthreads[0] = nthreads[1] =
|
|
nthreads[2] = 0;
|
|
#pragma omp target teams ompx_bare num_teams(64, 16, 8) thread_limit(32, 4, 2) \
|
|
map(tofrom : nblocks, nthreads)
|
|
{
|
|
get_gridsizes(nblocks, nthreads);
|
|
}
|
|
// CHECK: nblocks: 64 16 8, nthreads: 32 4 2
|
|
fprintf(stderr, "nblocks: %d %d %d, nthreads: %d %d %d\n", nblocks[0],
|
|
nblocks[1], nblocks[2], nthreads[0], nthreads[1], nthreads[2]);
|
|
|
|
return 0;
|
|
}
|