Job management, control flow
조회 수: 1 (최근 30일)
이전 댓글 표시
I work with large (0.2 - 1 Tb) sets of 3D image data. I would like to set up a queue within a function that reads in an 'on-deck' image into RAM while data is being processed on the GPU. I can sort out the details, but would be grateful if someone could help point me in the right direction to do the following:
Read in 2 files run loop1 on file1 ; end loop ; clear file 1
run loop1 on file 2; while running, load file3 into memory.
...and so on.
In other words, i need to essentially be able to send a child process to the gpu, and wait on its return value
댓글 수: 0
채택된 답변
Jon Boerner
2014년 10월 21일
편집: Jon Boerner
2014년 10월 21일
Hi Benjamin,
The easiest way to do this is probably using either the batch function, or the parfeval function in newer versions. Basically, you would use one of those functions to start a worker which would handle interfacing with the GPU, while the main thread moves on to loading the next file. The code might look something like:
loadedData = loaddata(...);
c = parcluster('local');
c.NumWorkers = 2; % You may want more workers depending on how many GPU's you have, etc.
j = batch(c,@myGPUFcn,1,{loadedData});
while(...)
loadedData = loadnextdata(...);
j.wait(); %Wait for GPU to finish in case file loaded faster
outputs = j.fetchOutputs;
end
function y = myGPUFcn(data)
% make gpuArray and perform operations on it
end
There are some details missing, but that would be the general approach. Using parfeval would be a very similar workflow. loaddata and loadnextdata are just place holders for however you load your files.
Let me know if you have any questions!
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 GPU Computing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!