Charge un kernel à partir d'un fichier cl.out
fonc=openclLoadFunction("filename.cl.out","kernelname");
Nom de fichier
Nom du kernel
Pointer sur un kernel.
fonc=openclLoadFunction(filename,kernelname)
permet de charger un kernel à partir d'un fichier .cl.out obtenu par
buildOpenCL. La valeur de retour est un pointeur, correspondant au kernel,
qu'il faudra passer ensuite à openclApplyFunction.
filename est le chemin vers le fichier cl.out. Le
chemin doit être absolu.
kernelname est le nom du kernel au sein du
fichier cl.
//--matrixAdd.cu-- extern "C" __global__ void matrixAdd( double* C, double* A, double* B, int M, int N) { int idx = blockIdx.x; int idy = blockIdx.y; int dx = blockDim.x; int dy = blockDim.y; int tx = threadIdx.x; int ty = threadIdx.y; int x=tx+dx*idx; int y=ty+dy*idy; if(x<M && y<N) C[ x + y*M ]= A[ x + y*M ] + B[ x+ y*M ]; } //--Scilab script-- A=ones(16,16);gA=openclToGpu(A) B=2*ones(16,16);gB=openclToGpu(B) C=0*ones(16,16);gC=openclToGpu(C) buildOpenCL(CUDAPATH+"/tests/unit_tests/"+"matrixAdd.cu"); fonc=openclLoadFunction("matrixAdd.cl.out","matrixAdd") lst=list(gC,gB,gA,16,16) openclApplyFunction(fonc,lst,16,16,1,1); C=openclFromGpu(gC); openclFree(gA); openclFree(gB); openclFree(gC); openclExit(); | ![]() | ![]() |