Skip to content

getting false negative error by SYCLomatic when migrating external CUDA host device function template #2192

Open

Description

@ArberSephirotheca

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<float> foo();
extern template foo1<double> foo();

int main(){
    foo1<float> foo();
}

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

Activity

  1. changed the title [-]getting false negative error by SYCLomatic when migrating external CUDA function template[/-] [+]getting false negative error by SYCLomatic when migrating external CUDA host device function template[/+] on Jul 23, 2024
  2. tomflinda commented on Jul 24, 2024

    @tomflinda
    Contributor

    @ArberSephirotheca reproduced, thanks for your report, and we will plan to fix it.

  3. ArberSephirotheca commented on Jul 25, 2024

    @ArberSephirotheca
    Author

    Thank you! @tomflinda

    I was wondering if this error hurt the later migration process even it is false negative? I tried to eliminate this error using user define rule to replace every extern template with empty line. However, the error still persist. it seems that user define rule is applied post migration? Can we decide when to apply the user define rule? (e.g. post migration vs pre migration)

  4. tomflinda commented on Jul 26, 2024

    @tomflinda
    Contributor

    @ArberSephirotheca, all user-defined rules are applied after the CUDA source code is parsed. Therefore, user-defined rules cannot eliminate the parsing error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions