I use a templated kernel that use a classe like this as parameter
#ifndef __test__
#define __test__
typedef struct
{
specific data...
} test_t;
Class test
{
public:
test_t data;
init(params)
{
cudaMallocManaged((void**)&data, sizeof(test_t));
//filling data
}
__device__ double3 compute(......)
{
//compute something using data
return result;
}
}```
Each acces to data leads to crash. Why?
The problem you have is not because you are using templates - that is fine. The problem you have is not because you are using a class as a template argument - that is certainly workable in CUDA. Problems accessing data in CUDA are common, but understanding them depends on specifics that you haven’t shown. You can find numerous questions that discuss various data access problems using classes in CUDA, as well as examples of using a class as a templated kernel template argument - its all possible.