Hi! I am using GPU cores to accelerate analysis of images stored in '.fits' files. For this I am using GPU coder, in which I am converting function (see below) to mex format, but it is giving error " fitsread is not supported for GPU code generation ".
%first function
function F=T1(m,n)
file = ['G:\spatial ent\Intensity Correlation Imaging\EI_10mW_G1000_et3.5ms_X1.fits'];
frame1=fitsread(file,'PixelRegion',{[1 64],[1 64],(1)});
F=frame1(m,n);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I have successfully generated mex file for trail function (see below) and with 5X increase in speed it is working propoerly.
%second function
function F=T1(m,n)
A=zeros(64);
F=A(m,n);
end
I used second function for trail to generate mex file which I called in the follwing code,
tic;
T=zeros(64);
for m=1:64
for n=1:64
T(m,n)= T1(m,n);
end
end
toc;
Thanks,

 採用された回答

Walter Roberson
Walter Roberson 2022 年 8 月 28 日

0 投票

The GPU does not have access to file I/O .
For example for fprintf()
"This function accepts GPU arrays, but does not run on a GPU."

3 件のコメント

Satyajeet Patil
Satyajeet Patil 2022 年 8 月 28 日
Thanks! what if I call the fit file before the mex function in main code?
example
file = ['G:\spatial ent\Intensity Correlation Imaging\EI_10mW_G1000_et3.5ms_X1.fits'];
frame1=fitsread(file,'PixelRegion',{[1 64],[1 64],(1)});
for m=1:64
for n=1:64
T1_mex(m,n)
end
end
where, T1_mex(m,n) is generated from below function
function F=T1(m,n)
F=frame1(m,n);
end
Walter Roberson
Walter Roberson 2022 年 8 月 28 日
frame1 would be an object. You would have to pass the object to the function. I doubt that you can use objects on gpu.
Walter Roberson
Walter Roberson 2022 年 8 月 28 日
Consider two possibilities:
  1. fitsread() returns a data structure of information about the file in the form of an object, and invoking the object with row and column values invokes action. In this case, if you move the action to the GPU then file I/O would have to take place on the GPU; OR
  2. fitsread() returns an array of data directly, and frame1(m,n) is direct indexing. In this case, your T1_mex would be plain array indexing. Moving that to the GPU would require that the entire array be transferred to the GPU, and indexing would be done on the GPU. However, indexing random elements on the GPU is one of the least efficient GPU operations (vectorized access to a slice of an array is much more efficient.) You would have higher efficiency leaving the array on the CPU and indexing there.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGPU Computing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by