mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 15:16:08 +00:00

Added option -foffload-implicit-host-device-templates which is off by default. When the option is on, template functions and specializations without host/device attributes have implicit host device attributes. They can be overridden by device template functions with the same signagure. They are emitted on device side only if they are used on device side. This feature is added as an extension. `__has_extension(cuda_implicit_host_device_templates)` can be used to check whether it is enabled. This is to facilitate using standard C++ headers for device. Fixes: https://github.com/llvm/llvm-project/issues/69956 Fixes: SWDEV-428314
23 lines
532 B
Plaintext
23 lines
532 B
Plaintext
// RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only %s
|
|
// RUN: %clang_cc1 -isystem %S/Inputs -fcuda-is-device -fsyntax-only %s
|
|
// RUN: %clang_cc1 -isystem %S/Inputs -foffload-implicit-host-device-templates -fsyntax-only %s
|
|
// RUN: %clang_cc1 -isystem %S/Inputs -foffload-implicit-host-device-templates -fcuda-is-device -fsyntax-only %s
|
|
|
|
#include <cuda.h>
|
|
|
|
template<typename T>
|
|
void tempf(T x) {
|
|
}
|
|
|
|
template<typename T>
|
|
__device__ void tempf(T x) {
|
|
}
|
|
|
|
void host_fun() {
|
|
tempf(1);
|
|
}
|
|
|
|
__device__ void device_fun() {
|
|
tempf(1);
|
|
}
|