Create methods in kernels

Hi
Is there any way to create methods in the kernel files that can be called from other methods in the kernel
eg creating the subSort() method in the example below?

Thanks,
Emer

__global__ void sortNonBitonicListOfLength4(int *array)
{	
     subSort(array, 0, 4);
     subSort(array, 4, 8);
}

//subSort() method



}```

Hello

This should be possible in the same way as in C: By declaring the function as a ‘device’ function (before the main kernel), e.g.

__device__ void subSort(int *array, int min, int max) { .... }

extern "C"
__global__ void sortNonBitonicListOfLength4(int *array)
{  
     subSort(array, 0, 4);
     subSort(array, 4, 8);
}

But from the signature, it looks like you are trying to do an recursive algorithm: Note that CUDA usually does not support recursion! Only the newest architectures (Fermi, Compute Capability 2.0 or higher) support recursive device functions. This should also work with JCuda, of course, but I could not yet test this.