开发者

parallel computing in C and mathematica

I have a core i7 lap-top which has 8 processors.

I want to run all these 8 processors simultaneously with the same p开发者_JAVA技巧iece of code (something like kernels in GPU programming) for example:-

// GPU programming code (kernel)
__kernel void set(__global int* list)
    int i = get_global_id();
    list[i] = i;
}

I want to do something like this in mathematica but with C code not OpenCL, or do that with pure C code.

clearly, I want to run a specific piece of code in all cores using mathematica or C.

sorry for being not that clear .. :)


You probably want to read about OpenMP.


If you're looking for ways to utilize all cores in Mathematica, there shouldn't be any need to involve C. Mathematica has fairly good parallelization functionality, for example using Parallelize:

In[1] := Parallelize[Select[Range[9000, 10000], PrimeQ[2^# - 1] &],
                     Method -> "FinestGrained"]
Out[1] = {9689, 9941}


Take a look at Grand Central Dispatch or OpenMP, both C-based APIs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜