OpenMP Test on Visual Studio


To use OpenMP on Visual Studio IDE, we should set in tools->options like..



Below code is to calculate pi using loop logic.
There are 5 case code.
0 case is for testing, openMP running well or not.

1 case is no treading, else 2~4 case is some different OpenMP threading case.

I am also not friendly with openMP, so I will refer this code when not remember well.
And I will add more useful technical code..

<gist>


</gist>


The result image tells us, OpenMP is certainly faster than no threading.



AMP dose run on my pc?, AMP(Accelerated Massive Parallelism)

AMP is abbreviation of Accelerated Massive Parallelism.
It is maintained by Microsoft and it run based on DirectX 11.
So as I know, AMP works in windows only, but there seems to be an attempt to run on other os.

Basically, AMP run on these environment
  • Windows 7, Windows 8, Windows Server 2008 R2, or Windows Server 2012 
  • DirectX 11 Feature Level 11.0 or later hardware 
  • For debugging on the software emulator, Windows 8 or Windows Server 2012 is required. For debugging on the hardware, you must install the drivers for your graphics card.
And no need to install for AMP, If you use Visual Studio.
So let's check your computer condition for parallel programming.


< code start >

< code end >

This is my condition.

We can check whether run or not by this.

if, accs.size() == 0, then there is no parallel machine.

I think AMP is easy and usefull to use parallel GPU programming.
This is useful for creating Windows applications.


reference site

Korean blog


MS site

MSDN AMP toturial



CUDA, GPGPU, Parallel communication pattern 5 -> Map, Gather, Scatter, Stencil, Transpose

1. Map : Tasks read from and write to specific data elements.


2. Gather : each calculation gathers input data elements together from different places to compute an output result.


3. Scatter : tasks compute where to write output


4. stencil


5. transpose



quiz


->
*out[i] = pi * in[i]
There is a 1-to-1 correspondence between the output and the input, so that's clearly an Map operation.

*out[i+j*128] = in[j+i*128];
i, j is reorder the array, so this is Transpose operation

*out[i-1] += pi * in[i]; out[i+1] += pi * in[i]
the value of calculation is placing the into a couple of different places in the output.
So Scatter operator

*out[i] = (in[i] + in[i-1] + in[i+1])* pi/3.0f;
every thread is writing a single location in the output array, and it's reading from multiple places in the input array, locations that it computes.
this looks very much like a stencil operation since it's reading from a local neighborhood, but because " if(i%2) ", it's not writing into every location.




image captured from UdaCity