
OpenMP Nesting of Regions restrictions say: - If a target update, target data, target enter data, or target exit data construct is encountered during execution of a target region, the behavior is unspecified. - If a target construct is encountered during execution of a target region and a device clause in which the ancestor device-modifier appears is not present on the construct, the behavior is unspecified. That wording is about the dynamic (runtime) behavior, not about lexical nesting, so while it is UB if omp target * is encountered in the target region, we need to make it compile and link (for lexical nesting of target * inside of target we actually emit a warning). To make this work, I had to do multiple changes. One was to mark .omp_data_{sizes,kinds}.* variables when static as "omp declare target". Another one was to add stub GOMP_target* entrypoints to nvptx and gcn libgomp.a. The entrypoint functions shouldn't be called or passed in the offload regions, otherwise libgomp: cuLaunchKernel error: too many resources requested for launch was reported; fixed by changing those arguments of calls to GOMP_target_ext to NULL. And we didn't mark the entrypoints "omp target entrypoint" when the caller has been "omp declare target". 2021-05-26 Jakub Jelinek <jakub@redhat.com> PR libgomp/100573 gcc/ * omp-low.c: Include omp-offload.h. (create_omp_child_function): If current_function_decl has "omp declare target" attribute and is_gimple_omp_offloaded, remove that attribute from the copy of attribute list and add "omp target entrypoint" attribute instead. (lower_omp_target): Mark .omp_data_sizes.* and .omp_data_kinds.* variables for offloading if in omp_maybe_offloaded_ctx. * omp-offload.c (pass_omp_target_link::execute): Nullify second argument to GOMP_target_data_ext in offloaded code. libgomp/ * config/nvptx/target.c (GOMP_target_ext, GOMP_target_data_ext, GOMP_target_end_data, GOMP_target_update_ext, GOMP_target_enter_exit_data): New dummy entrypoints. * config/gcn/target.c (GOMP_target_ext, GOMP_target_data_ext, GOMP_target_end_data, GOMP_target_update_ext, GOMP_target_enter_exit_data): Likewise. * testsuite/libgomp.c-c++-common/for-3.c (DO_PRAGMA, OMPTEAMS, OMPFROM, OMPTO): Define. (main): Remove #pragma omp target teams around all the tests. * testsuite/libgomp.c-c++-common/target-41.c: New test. * testsuite/libgomp.c-c++-common/target-42.c: New test.
116 lines
2.2 KiB
C
116 lines
2.2 KiB
C
/* { dg-additional-options "-std=gnu99" { target c } } */
|
|
|
|
extern
|
|
#ifdef __cplusplus
|
|
"C"
|
|
#endif
|
|
void abort ();
|
|
|
|
#define M(x, y, z) O(x, y, z)
|
|
#define O(x, y, z) x ## _ ## y ## _ ## z
|
|
|
|
#define DO_PRAGMA(x) _Pragma (#x)
|
|
#define OMPTEAMS DO_PRAGMA (omp target teams)
|
|
#define OMPFROM(v) DO_PRAGMA (omp target update from(v))
|
|
#define OMPTO(v) DO_PRAGMA (omp target update to(v))
|
|
|
|
#pragma omp declare target
|
|
|
|
#define F distribute
|
|
#define G d
|
|
#define S
|
|
#define N(x) M(x, G, normal)
|
|
#include "for-2.h"
|
|
#undef S
|
|
#undef N
|
|
#undef F
|
|
#undef G
|
|
|
|
#define F distribute
|
|
#define G d_ds128
|
|
#define S dist_schedule(static, 128)
|
|
#define N(x) M(x, G, normal)
|
|
#include "for-2.h"
|
|
#undef S
|
|
#undef N
|
|
#undef F
|
|
#undef G
|
|
|
|
#define F distribute simd
|
|
#define G ds
|
|
#define S
|
|
#define N(x) M(x, G, normal)
|
|
#include "for-2.h"
|
|
#undef S
|
|
#undef N
|
|
#undef F
|
|
#undef G
|
|
|
|
#define F distribute simd
|
|
#define G ds_ds128
|
|
#define S dist_schedule(static, 128)
|
|
#define N(x) M(x, G, normal)
|
|
#include "for-2.h"
|
|
#undef S
|
|
#undef N
|
|
#undef F
|
|
#undef G
|
|
|
|
#define F distribute parallel for
|
|
#define G dpf
|
|
#include "for-1.h"
|
|
#undef F
|
|
#undef G
|
|
|
|
#define F distribute parallel for dist_schedule(static, 128)
|
|
#define G dpf_ds128
|
|
#include "for-1.h"
|
|
#undef F
|
|
#undef G
|
|
|
|
#define F distribute parallel for simd
|
|
#define G dpfs
|
|
#include "for-1.h"
|
|
#undef F
|
|
#undef G
|
|
|
|
#define F distribute parallel for simd dist_schedule(static, 128)
|
|
#define G dpfs_ds128
|
|
#include "for-1.h"
|
|
#undef F
|
|
#undef G
|
|
|
|
#pragma omp end declare target
|
|
|
|
int
|
|
main ()
|
|
{
|
|
int err = 0;
|
|
err |= test_d_normal ();
|
|
err |= test_d_ds128_normal ();
|
|
err |= test_ds_normal ();
|
|
err |= test_ds_ds128_normal ();
|
|
err |= test_dpf_static ();
|
|
err |= test_dpf_static32 ();
|
|
err |= test_dpf_auto ();
|
|
err |= test_dpf_guided32 ();
|
|
err |= test_dpf_runtime ();
|
|
err |= test_dpf_ds128_static ();
|
|
err |= test_dpf_ds128_static32 ();
|
|
err |= test_dpf_ds128_auto ();
|
|
err |= test_dpf_ds128_guided32 ();
|
|
err |= test_dpf_ds128_runtime ();
|
|
err |= test_dpfs_static ();
|
|
err |= test_dpfs_static32 ();
|
|
err |= test_dpfs_auto ();
|
|
err |= test_dpfs_guided32 ();
|
|
err |= test_dpfs_runtime ();
|
|
err |= test_dpfs_ds128_static ();
|
|
err |= test_dpfs_ds128_static32 ();
|
|
err |= test_dpfs_ds128_auto ();
|
|
err |= test_dpfs_ds128_guided32 ();
|
|
err |= test_dpfs_ds128_runtime ();
|
|
if (err)
|
|
abort ();
|
|
return 0;
|
|
}
|