In a nutshell, this moves our libomptarget code to populate the offload subproject. With this commit, users need to enable the new LLVM/Offload subproject as a runtime in their cmake configuration. No further changes are expected for downstream code. Tests and other components still depend on OpenMP and have also not been renamed. The results below are for a build in which OpenMP and Offload are enabled runtimes. In addition to the pure `git mv`, we needed to adjust some CMake files. Nothing is intended to change semantics. ``` ninja check-offload ``` Works with the X86 and AMDGPU offload tests ``` ninja check-openmp ``` Still works but doesn't build offload tests anymore. ``` ls install/lib ``` Shows all expected libraries, incl. - `libomptarget.devicertl.a` - `libomptarget-nvptx-sm_90.bc` - `libomptarget.rtl.amdgpu.so` -> `libomptarget.rtl.amdgpu.so.18git` - `libomptarget.so` -> `libomptarget.so.18git` Fixes: https://github.com/llvm/llvm-project/issues/75124 --------- Co-authored-by: Saiyedul Islam <Saiyedul.Islam@amd.com>
102 lines
2.2 KiB
C
102 lines
2.2 KiB
C
// RUN: %libomptarget-compile-generic -fopenmp-version=51
|
|
// RUN: %libomptarget-run-generic 2>&1 \
|
|
// RUN: | %fcheck-generic
|
|
|
|
// UNSUPPORTED: amdgcn-amd-amdhsa
|
|
|
|
#include <omp.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define N 1024
|
|
#define FROM 64
|
|
#define LENGTH 128
|
|
|
|
void foo() {
|
|
const int device_id = omp_get_default_device();
|
|
float *A;
|
|
A = (float *)omp_target_alloc((FROM + LENGTH) * sizeof(float), device_id);
|
|
|
|
float *A_dev = NULL;
|
|
#pragma omp target has_device_addr(A[FROM : LENGTH]) map(A_dev)
|
|
{ A_dev = A; }
|
|
// CHECK: Success
|
|
if (A_dev == NULL || A_dev != A)
|
|
fprintf(stderr, "Failure %p %p \n", A_dev, A);
|
|
else
|
|
fprintf(stderr, "Success\n");
|
|
}
|
|
|
|
void bar() {
|
|
short x[10];
|
|
short *xp = &x[0];
|
|
|
|
x[1] = 111;
|
|
#pragma omp target data map(tofrom : xp[0 : 2]) use_device_addr(xp[0 : 2])
|
|
#pragma omp target has_device_addr(xp[0 : 2])
|
|
{
|
|
xp[1] = 222;
|
|
// CHECK: 222
|
|
printf("%d %p\n", xp[1], &xp[1]);
|
|
}
|
|
// CHECK: 222
|
|
printf("%d %p\n", xp[1], &xp[1]);
|
|
}
|
|
|
|
void moo() {
|
|
short *b = malloc(sizeof(short));
|
|
b = b - 1;
|
|
|
|
b[1] = 111;
|
|
#pragma omp target data map(tofrom : b[1]) use_device_addr(b[1])
|
|
#pragma omp target has_device_addr(b[1])
|
|
{
|
|
b[1] = 222;
|
|
// CHECK: 222
|
|
printf("%hd %p %p %p\n", b[1], b, &b[1], &b);
|
|
}
|
|
// CHECK: 222
|
|
printf("%hd %p %p %p\n", b[1], b, &b[1], &b);
|
|
}
|
|
|
|
void zoo() {
|
|
short x[10];
|
|
short *(xp[10]);
|
|
xp[1] = &x[0];
|
|
short **xpp = &xp[0];
|
|
|
|
x[1] = 111;
|
|
#pragma omp target data map(tofrom : xpp[1][1]) use_device_addr(xpp[1][1])
|
|
#pragma omp target has_device_addr(xpp[1][1])
|
|
{
|
|
xpp[1][1] = 222;
|
|
// CHECK: 222
|
|
printf("%d %p %p\n", xpp[1][1], xpp[1], &xpp[1][1]);
|
|
}
|
|
// CHECK: 222
|
|
printf("%d %p %p\n", xpp[1][1], xpp[1], &xpp[1][1]);
|
|
}
|
|
void xoo() {
|
|
short a[10], b[10];
|
|
a[1] = 111;
|
|
b[1] = 111;
|
|
#pragma omp target data map(to : a[0 : 2], b[0 : 2]) use_device_addr(a, b)
|
|
#pragma omp target has_device_addr(a) has_device_addr(b[0])
|
|
{
|
|
a[1] = 222;
|
|
b[1] = 222;
|
|
// CHECK: 222 222
|
|
printf("%hd %hd %p %p %p\n", a[1], b[1], &a, b, &b);
|
|
}
|
|
// CHECK:111
|
|
printf("%hd %hd %p %p %p\n", a[1], b[1], &a, b, &b); // 111 111 p1d p2d p3d
|
|
}
|
|
int main() {
|
|
foo();
|
|
bar();
|
|
moo();
|
|
zoo();
|
|
xoo();
|
|
return 0;
|
|
}
|