Hi,

I use mex-Files to replace some matlab functions.

I was surprised when I measured the time need for the calculation.

I use the “tic” and “toc” command to measure the time in Matlab (approximately 95ms).

The I measured the time in the mex-File with

cudaEventCreate(&start);

cudaEventCreate(&stop);

cudaEventRecord( start, 0 )

cudaEventRecord( stop, 0 );

cudaEventSynchronize( stop );

cudaEventElapsedTime( &elapsedtime, start, stop );

and I measure about 3ms.

So i measured the time for a (nearly) empty mex-File with “tic”“toc” in the matlab script: 3.5ms.

Then I put a “cudaMalloc” in the mex-File and measured a time of over 70ms.

Has anyone an idea why it took so much time even if there is no calculation?

Did it take such a lon time to “initialize” the graphic card?

Another Problem is, that I want to split the mex-File into two parts. One part is called only once and ccontains the Copy of the data from the host to the device and the other mex-file is called in every iteration and contains the calculation and only one small copy of new data.

I read that the data on the graphic card is valid until ie close matlab.

But i dont know how to save the Adresses of the data on the graphic card to matlab and then load them into the next mex-File.

I have only experience in save the value of a variable in an mxArray but dont know how to put the address of the variable into an mxArray to transfer it into matlab.

I hope someone can give me a tip.

perhaps it might help:

I use the following Systems (with the same observations)

Vista64bit Core2Duo 2,7GHz Geforce8800GT Matlab2009b

Vista 32bit Core2Duo 2,1GHZ Geforce8400M GS Matlab2008a

And at the end: Sorry for my bad English.