#ifndef __MYREDUCTION_CUH__
#define __MYREDUCTION_CUH__

/*template <class T> __device__ T TestFunc(T Const, int i){
  return (T)1.0;//Const*((T)(1-2*(i%2)));
}*/

#include "InitArrayFunc.hpp"
 
template <class T>
__global__ void InitTestArray_kernel(
    T *d_X,
    int N,
    T Const
){
    const int      tid = blockDim.x * blockIdx.x + threadIdx.x;
    const int THREAD_N = blockDim.x * gridDim.x;
    int pos=tid;
    
    while (pos < N){
      d_X[pos] = TestFunc(Const,pos);
      pos+=THREAD_N;
    }
}

template <class T>
void 
GPU_InitTestArray(T *d_X, int N, T Const,int threads, int blocks)
{
  dim3 dimBlock(threads, 1, 1);
  dim3 dimGrid(blocks, 1, 1);
  
  InitTestArray_kernel<T><<< dimGrid, dimBlock>>>(d_X,N,Const);
}

#endif
