Convert matlab code to Cuda c++ (FFT of 2d Images)

조회 수: 5 (최근 30일)
alaa Afeef
alaa Afeef 2016년 8월 26일
답변: Kanishk 2025년 7월 8일
How can the below Matlab code be converted into Cuda c++? It is to apply FFT of the 2D images.
Input: ptycho.m_wp; %4 dimensional matrix of size (65 x 65 of 2D images of 90 x 90 pixels)
size4D=[65,65,90,90];
size4D = [size(ptycho.m_wp,1), size(ptycho.m_wp,2), ptycho.ObjSize(1), ptycho.ObjSize(2)];
mean_m_wp=zeros(size(ptycho.m_wp,1),size(ptycho.m_wp,2));
sumI=0;
fprintf('FT{M} w.r.t Probe Positions...')
% allocate memory for G matrix
G_wp = complex(zeros(size4D));
disp('*****');
disp('Looping through FFT on CPU');
for i = 1:size4D(1)
for j=1:size4D(2)
G_wp(i,j,:,:) = fftshift(fft2(ifftshift( ImagePadMean(squeeze(ptycho.m_wp(i,j,:,:)),ptycho.ObjSize))));
end
end
mean_m_wp = mean(mean(ptycho.m_wp,4),3);
sumI = sum(ptycho.m_wp(:));

답변 (1개)

Kanishk
Kanishk 2025년 7월 8일
Hello Alaa,
You can use the "GPU Coder" application in MATLAB to generate CUDA C++ code from MATLAB code. You can generate CUDA C++ source code, static libraries, dynamically linked libraries, and executables that you can then integrate into existing CUDA C++ applications outside of MATLAB.
The application is accessible from toolstrip on Apps tab, under Code Generation.
You can learn more about 'GPU Coder' by following this documentation.
Cheers!!

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by