У меня есть эти функции шаблона для использования встроенного на устройстве с CUDA
template <class T> __device__ inline T& cmin(T&a,T&b){return (a<b)?(a):(b);};
template <class T> __device__ inline T& cmax(T&a,T&b){return (a>b)?(a):(b);};
В коде у меня есть
cmin(z[i],y[j])-cmax(x[i],z[j])
для массивов int x, y и z. Я получаю ошибку:
ошибка: ни один экземпляр шаблона функции "cmax" не соответствует списку аргументов
argument types are: (int, int)
Я получаю ошибку для cmax, но не для cmin. Если я заменю строку cmax на
#define cmax(a,b) ((a)>(b))?(a):(b)
это прекрасно работает, но я не хочу #defines, они проблематичны. Что, черт возьми, здесь происходит?
EDIT:
вот полная функция вызова. раз typedef int.
__global__ void compute_integral_y_isums(times * admit, times * discharge, times * Mx, times * isums, ar_size N){
// computes the sums for each j
// blocks on j,
// threads on i since we will be summing over i.
// sumation over J should be handled by either a different kernel or on the cpu.
ar_index tid = threadIdx.x;
ar_index i = blockIdx.x; // summing for patient i
ar_index j = threadIdx.x; // across other patients j
__shared__ times cache[threadsPerBlock];
times Iy = 0;
while(j<N){
// R code: max(0,min(Mx[i],d3[j,'Discharge.time'])-max(d3[i,'Admission.time'],Mx[j]))
times imin = cmin(Mx[i],discharge[j]);
times imax = cmax(admit[i],Mx[j]);
Iy += cmax(0,imin-imax);
j += blockDim.x;
}
cache[tid] = Iy;
__syncthreads();
// reduce
/***REMOVED***/
}