SYCLomatic
SYCLomatic copied to clipboard
getting false negative error by SYCLomatic when migrating external CUDA host device function template
Describe the bug
When I try to migrate the code containing extern template
#include <cuda_runtime.h>
template <typename Outtype>
class foo1{};
template <typename Out>
__device__ __host__ foo1<Out> foo()
{
return foo1<Out>{};
}
extern template foo1<float> foo();
extern template foo1<double> foo();
int main(){
foo1<float> foo();
}
I got the following errors:
error: explicit instantiation of 'foo' does not refer to a function template, variable template, member function, member class, or static data member
16 | extern template foo1<float> foo();
note: candidate template ignored: target attributes do not match
8 | __device__ __host__ foo1<Out> foo()
error: explicit instantiation of 'foo' does not refer to a function template, variable template, member function, member class, or static data member
17 | extern template foo1<double> foo();
note: candidate template ignored: target attributes do not match
8 | __device__ __host__ foo1<Out> foo()
code after migration:
#include <sycl/sycl.hpp>
#include <dpct/dpct.hpp>
template <typename Outtype>
class foo1{};
template <typename Out>
foo1<Out> foo()
{
return foo1<Out>{};
}
extern template foo1<float> foo();
extern template foo1<double> foo();
int main(){
foo1<float> foo();
}
However, icpx is able to compile the migrated code without any issues.
To reproduce
#include <cuda_runtime.h>
template <typename Outtype> class foo1{};
template <typename Out> device host foo1<Out> foo() {
return foo1<Out>{};
}
extern template foo1
int main(){
foo1
Environment
- OS: Linux
- Target device and vendor: Nvidia GPU
- DPC++ version: Intel(R) oneAPI DPC++/C++ Compiler 2024.2.0 (2024.2.0.20240602)
Additional context
No response