-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMP][FIX] Ensure we allow shared libraries without kernels (#74532)
This fixes two bugs and adds a test for them: - A shared library with declare target functions but without kernels should not error out due to missing globals. - Enabling LIBOMPTARGET_INFO=32 should not deadlock in the presence of indirect declare targets.
- Loading branch information
Showing
6 changed files
with
51 additions
and
12 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,3 @@ | ||
|
||
int func() { return 42; } | ||
#pragma omp declare target indirect to(func) |
22 changes: 22 additions & 0 deletions
22
openmp/libomptarget/test/offloading/shared_lib_fp_mapping.c
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,22 @@ | ||
// clang-format off | ||
// RUN: %clang-generic -fPIC -shared %S/../Inputs/declare_indirect_func.c -o %T/liba.so -fopenmp-version=51 | ||
// RUN: %libomptarget-compile-generic -L %T -l a -o %t -fopenmp-version=51 | ||
// RUN: env LIBOMPTARGET_INFO=32 LD_LIBRARY_PATH=%T:$LD_LIBRARY_PATH %t | %fcheck-generic | ||
// clang-format on | ||
|
||
#include <stdio.h> | ||
|
||
extern int func(); // Provided in liba.so, returns 42 | ||
typedef int (*fp_t)(); | ||
|
||
int main() { | ||
int x = 0; | ||
fp_t fp = &func; | ||
printf("TARGET\n"); | ||
#pragma omp target map(from : x) | ||
x = fp(); | ||
// CHECK: Copying data from device to host, {{.*}} Size=8 | ||
// CHECK: Copying data from device to host, {{.*}} Size=4 | ||
// CHECK: 42 | ||
printf("%i\n", x); | ||
} |