llvm-project/clang/test/SemaCUDA/implicit-host-device-fun.cu
Yaxun (Sam) Liu 9774d0ce5f
[CUDA][HIP] Make template implicitly host device (#70369)
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
2023-11-09 20:36:38 -05:00

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);
}