[OpenMP][libomptarget] Enable requires flags for target libraries.
Summary:
Target link variables are currently implemented by creating a copy of the variables on the device side and unified memory never gets exploited.
When the prgram uses the:
```
#pragma omp requires unified_shared_memory
```
directive in conjunction with a declare target link, the linked variable is no longer allocated on the device and the host version is used instead.
This behavior is overridden by performing an explicit mapping.
A Clang side patch is required.
Reviewers: ABataev, AlexEichenberger, grokos, Hahnfeld
Reviewed By: AlexEichenberger, grokos, Hahnfeld
Subscribers: Hahnfeld, jfb, guansong, jdoerfert, openmp-commits
Tags: #openmp
Differential Revision: https://reviews.llvm.org/D60223
llvm-svn: 361294
2019-05-22 03:35:02 +08:00
|
|
|
// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-aarch64-unknown-linux-gnu 2>&1 | %fcheck-aarch64-unknown-linux-gnu -allow-empty -check-prefix=DEBUG
|
|
|
|
// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-powerpc64-ibm-linux-gnu 2>&1 | %fcheck-powerpc64-ibm-linux-gnu -allow-empty -check-prefix=DEBUG
|
|
|
|
// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-powerpc64le-ibm-linux-gnu 2>&1 | %fcheck-powerpc64le-ibm-linux-gnu -allow-empty -check-prefix=DEBUG
|
|
|
|
// RUN: %libomptarget-compile-x86_64-pc-linux-gnu && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-x86_64-pc-linux-gnu 2>&1 | %fcheck-x86_64-pc-linux-gnu -allow-empty -check-prefix=DEBUG
|
2020-07-28 17:08:24 +08:00
|
|
|
// RUN: %libomptarget-compile-nvptx64-nvidia-cuda && env LIBOMPTARGET_DEBUG=1 %libomptarget-run-nvptx64-nvidia-cuda 2>&1 | %fcheck-nvptx64-nvidia-cuda -allow-empty -check-prefix=DEBUG
|
[OpenMP][libomptarget] Enable requires flags for target libraries.
Summary:
Target link variables are currently implemented by creating a copy of the variables on the device side and unified memory never gets exploited.
When the prgram uses the:
```
#pragma omp requires unified_shared_memory
```
directive in conjunction with a declare target link, the linked variable is no longer allocated on the device and the host version is used instead.
This behavior is overridden by performing an explicit mapping.
A Clang side patch is required.
Reviewers: ABataev, AlexEichenberger, grokos, Hahnfeld
Reviewed By: AlexEichenberger, grokos, Hahnfeld
Subscribers: Hahnfeld, jfb, guansong, jdoerfert, openmp-commits
Tags: #openmp
Differential Revision: https://reviews.llvm.org/D60223
llvm-svn: 361294
2019-05-22 03:35:02 +08:00
|
|
|
// REQUIRES: libomptarget-debug
|
|
|
|
|
|
|
|
/*
|
|
|
|
Test for the 'requires' clause check.
|
|
|
|
When a target region is used, the requires flags are set in the
|
|
|
|
runtime for the entire compilation unit. If the flags are set again,
|
|
|
|
(for whatever reason) the set must be consistent with previously
|
|
|
|
set values.
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <omp.h>
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Various definitions copied from OpenMP RTL
|
|
|
|
|
|
|
|
extern void __tgt_register_requires(int64_t);
|
|
|
|
|
|
|
|
// End of definitions copied from OpenMP RTL.
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void run_reg_requires() {
|
|
|
|
// Before the target region is registered, the requires registers the status
|
|
|
|
// of the requires clauses. Since there are no requires clauses in this file
|
|
|
|
// the flags state can only be OMP_REQ_NONE i.e. 1.
|
|
|
|
|
|
|
|
// This is the 2nd time this function is called so it should print the debug
|
|
|
|
// info belonging to the check.
|
|
|
|
__tgt_register_requires(1);
|
|
|
|
__tgt_register_requires(1);
|
|
|
|
// DEBUG: New requires flags 1 compatible with existing 1!
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
int main() {
|
|
|
|
run_reg_requires();
|
|
|
|
|
|
|
|
// This also runs reg requires for the first time.
|
|
|
|
#pragma omp target
|
|
|
|
{}
|
|
|
|
|
|
|
|
return 0;
|
2019-08-08 01:29:45 +08:00
|
|
|
}
|