kernelLauncher or cuLaunchKernel

hello,

I use jcuda for complex computations look like this

memoryAllocation and copyFromHostToDevice
for(){
	for(){
		launch function 1 with parameter set 1;
		launch function 2 with parameter set 2;
		launch function 1 with parameter set 3;
		launch function 2 with parameter set 4;
	}
	copyFromDeviceToHost
}
memoryFree

I always use kernelLauncher.setup(…).call(…) for function launch and it works good.

I see in http://jcuda.org/tutorial/TutorialIndex.html you use ‘cuLaunchKernel(kernelParameters)’ where ‘kernelParameters=Pointer.to(…);’

When I use cuLaunchKernel I can compile the code but the program throws ‘EXCEPTION_ACCESS_VIOLATION’ after first ‘for’ cycle.

I consider that the ‘cuLaunchKernel(kernelParameters)’ method is not suitable for my case.
Am I right?

P.S. In ‘cuLaunchKernel(kernelParameters)’ case you don’t use (as I see in tutorial) ‘memoryAllocation’ and ‘memoryCopy‘. Does it mean that ‘kernelParameters=Pointer.to(…);’ was used in this case instead of ‘memoryAllocation’ and ‘memoryCopy‘?

Thank you again!

Hello

The question is not entirely clear. But a general remark: The KernelLauncher class is only a utility class. Loading modules and launching kernels may be difficult. (And it was even more difficult with older CUDA versions). So I created this class to make it a little bit easier (or at least, more convenient). Especially when someone only wants to quickly write+test a kernel: Then the KernelLauncher may reduce the amount of “boilerplate code” that is required on the host side.

BUT: Everything that you do with the KernelLauncher is also possible without the KernelLauncher. So what you are doing with kernelLauncher.setup(…).call(…) can also be done with cuLaunchKernel. When you receive an EXCEPTION_ACCESS_VIOLATION, then there is something wrong. But I can’t say what is wrong without more code…

Also note that the Tutorial only shows the basic invocation of a kernel. It refers to the JCudaVectorAdd example, which is a complete example that shows how a kernel is loaded and executed, and which could serve as a starting point for first own programs.