/* * Example of how to use the mxGPUArray API in a MEX file. This example shows * how to write a MEX function that takes a gpuArray input and returns a * gpuArray output, e.g. B=mexFunction(A). * * Copyright 2012 The MathWorks, Inc. */ #include #include #include #include #include #include "mex.h" #include "gpu/mxGPUArray.h" #include #include #include using namespace std; const int Nthreads = 1024, nblock = 32; ////////////////////////////////////////////////////////////////////////////////////////// __global__ void crossFilter(const double *Params, const float *W1, const float *W2, const float *UtU, float *WtW){ __shared__ float shW1[nblock*81], shW2[nblock*81]; float x; int nt0, tidx, tidy , bidx, bidy, i, NT, Nfilt, t; tidx = threadIdx.x; tidy = threadIdx.y; bidx = blockIdx.x; bidy = blockIdx.y; Nfilt = (int) Params[1]; nt0 = (int) Params[9]; while(tidx>>(d_Params, d_W1, d_W2, d_UtU, d_WtW); plhs[0] = mxGPUCreateMxArrayOnGPU(WtW); cudaFree(d_Params); mxGPUDestroyGPUArray(WtW); mxGPUDestroyGPUArray(W1); mxGPUDestroyGPUArray(W2); mxGPUDestroyGPUArray(UtU); }