Speeding up matrix expotentials by using GPU
Hey all:
I am trying to accelerate the speed of calculation of high dimisional matrix expotential by using GPU, but I find that the speed of calculating them on CPU is faster than GPU, and I can’t find where the problem is. The code is:
dev = gpuDevice();
CPU_time = 0;
GPU_time = 0;
for i = 1:10
CPU_matrix = rand(4096, 4096);
GPU_matrix = gpuArray(complex(CPU_matrix));
tic;
Exp_CPU = expm(-1i * CPU_matrix);
CPU_time = CPU_time + toc;
tic;
Exp_GPU = expm(-1i * GPU_matrix);
GPU_time = GPU_time + toc;
end
disp("CPU time:" + string(CPU_time));
disp("GPU time:" + string(GPU_time));
I tested this code using my computer, and its CPU configuration is: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz 2.59 GHz, RAM 16 GB. Its GPU configuration is: NVIDIA GeForce GTX 1650. The final result is:
CPU time:452.1338
GPU time:915.5892
Why the speed of GPU is slower than CPU?
ThanksHey all:
I am trying to accelerate the speed of calculation of high dimisional matrix expotential by using GPU, but I find that the speed of calculating them on CPU is faster than GPU, and I can’t find where the problem is. The code is:
dev = gpuDevice();
CPU_time = 0;
GPU_time = 0;
for i = 1:10
CPU_matrix = rand(4096, 4096);
GPU_matrix = gpuArray(complex(CPU_matrix));
tic;
Exp_CPU = expm(-1i * CPU_matrix);
CPU_time = CPU_time + toc;
tic;
Exp_GPU = expm(-1i * GPU_matrix);
GPU_time = GPU_time + toc;
end
disp("CPU time:" + string(CPU_time));
disp("GPU time:" + string(GPU_time));
I tested this code using my computer, and its CPU configuration is: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz 2.59 GHz, RAM 16 GB. Its GPU configuration is: NVIDIA GeForce GTX 1650. The final result is:
CPU time:452.1338
GPU time:915.5892
Why the speed of GPU is slower than CPU?
Thanks Hey all:
I am trying to accelerate the speed of calculation of high dimisional matrix expotential by using GPU, but I find that the speed of calculating them on CPU is faster than GPU, and I can’t find where the problem is. The code is:
dev = gpuDevice();
CPU_time = 0;
GPU_time = 0;
for i = 1:10
CPU_matrix = rand(4096, 4096);
GPU_matrix = gpuArray(complex(CPU_matrix));
tic;
Exp_CPU = expm(-1i * CPU_matrix);
CPU_time = CPU_time + toc;
tic;
Exp_GPU = expm(-1i * GPU_matrix);
GPU_time = GPU_time + toc;
end
disp("CPU time:" + string(CPU_time));
disp("GPU time:" + string(GPU_time));
I tested this code using my computer, and its CPU configuration is: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz 2.59 GHz, RAM 16 GB. Its GPU configuration is: NVIDIA GeForce GTX 1650. The final result is:
CPU time:452.1338
GPU time:915.5892
Why the speed of GPU is slower than CPU?
Thanks gpu, matrix, matlab, time, expotential MATLAB Answers — New Questions