Open main menu

CDOT Wiki β


GPU621/Threadless Horsemen

1,206 bytes added, 12:28, 26 November 2018
OpenMP vs Julia Code
More code here:
* If you don't care about using Threads, Julia has some features called macros which look similar to OpenMP's parallel constructs
* OpenMP of course uses multi-threading, whereas Julia uses Tasks, which is what they call their coroutines / fibers
* The following is a comparison of parallel reduction in OpenMP and Julia
{| class="wikitable"
! OpenMP
! Julia
template <typename T>
T reduce(
const T* in, // points to the data set
int n, // number of elements in the data set
T identity // initial value
) {
T accum = identity;
#pragma omp parallel for reduction(+:accum)
for (int i = 0; i < n; i++)
accum += in[i];
return accum;
a = randn(1000)
@distributed (+) for i = 1:100000
* Note: Looks like Julia used to have a macro called @parallel so you could use, say, @parallel for, but it seems like it was deprecated in favour of @distributed
== OpenMP vs Julia Results ==