You don't need to disable JIT acceleration. Rather, you need to measure using timeit and gputimeit like so:
a = ones([100, 100], 'single');
h = a;
aa = gpuArray(a);
hh = gpuArray(h);
cpuTime = timeit(@() conv2(h, a, 'full'), 1);
gpuTime = gputimeit(@() conv2(hh, aa, 'full'), 1);
Why you might want to do this:
- MATLAB uses lazy evaluation to schedule the operations on your GPU, which introduces some asynchronicity in the GPU's behaviour. The same mechanism is not used on the CPU.
- gputimeit takes lazy evaluation into consideration and also repeats the measure several times, weighing caching effects, overheads, and first-time costs.
- timeit also repeats the measure several times, but it doesn't take lazy evaluation into consideration.
- tic/toc neither repeat the measure nor takes lazy evaluation into consideration.
- the profiler is somewhat similar to tic/toc but it also introduces some overhead in the measurement because it has to trace the whole call stack (which is why is useful for investigating rather than extracting rigorous measurements).
What results do you get? Let us know.
Given your setup, it woudln't be strange if gpuTime>cpuTime. Laptop GPUs are usually not optimized for computing, and it might be the case that yours is driving the graphics too.