如何在GPU上运行Matlab函数?

时间:2019-01-22 03:11:37

标签: matlab parallel-processing gpu spmd gpuarray

我想运行由3位启用GPU的工作程序组成的并行计算程序。我尝试使用gpuArray,但速度似乎没有差异。 我的编码如下所示:

function [output,frequency] = spmdfunc(music)
fid = fopen('music.mp3', 'r', 'b'); 

g = uint8(fread(fid, 'ubit1')');
h = gpuArray(g);
x = gather(h);

while ( a+31 <= numel(x) )   
   if( x(a:a+14) == syncword)
      poolobj = parpool (3);

      spmd
        if labindex == 1
           afr = dsp.AudioFileReader(%Content);

           while true
              % Content
           end 

           labSend(2, [])
           release(afr)

         elseif labindex == 2
            while true
               % Content

                  if isempty(frame)
                     labSend(3, []);
                  break
                  end
             end
          else 
             while true

                if isempty (frame)          
                break
                end

                length = numel(output(1,:));
                output(1,length+1:PCM_length+1152) = [samples(1,:) samples(3,:)]; 
                output(2,length+1:PCM_length+1152) = [samples(2,:) samples(4,:)]; 
              end 

           end %labindex
        end %spmd end

谢谢。

0 个答案:

没有答案