Can I simulate this example (diffraction pattern) on my CPU not my GPU?
    3 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Muhamed Sewidan
 le 1 Sep 2020
  
    
    
    
    
    Commenté : Muhamed Sewidan
 le 1 Sep 2020
            I tried to apply this example but it doesn't work, because I don't have an external Nividea GPU, I have an intel internal GPU.
Thus, can I apply this example with my CPU.
0 commentaires
Réponse acceptée
  Raymond Norris
    
 le 1 Sep 2020
        Hi Muhamed,
In the best situation, by simply casting your data to a GPU, the code following the data creation will run, so long as all of the functions are overloaded for GPU arrays.  For example
% CPU version
a = rand(10);
b = fft(a);
% GPU version
a = gpuArray.rand(10);     % Create GPU array instead of a standard numeric array
b = fft(a);                % Call your code as you normally would
In the example you've highlited, the code should run fine by just making the following change
[gx, gy] = meshgrid( gpuArray.colon( -1, 1/N2, (N2-1)/N2 ) );
to
[gx, gy] = meshgrid( colon( -1, 1/N2, (N2-1)/N2 ) );
or what would be more common coded as
[gx, gy] = meshgrid(-1:1/N2:(N2-1)/N2);
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur GPU Computing dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

