ChinaUnix.net
相关文章推荐:

OpenMP 线程 类 成员函数

一个openmp线程c++程序,要在程序中多个线程同时调用一个函数的话,会出现问题吗? 测试结果总和单线程的结果不一致,但是差别很小,不知道为什么。示例代码如下: #ifdef openmp omp_set_num_threads(NUM_THREADS); // multhreads for #pragma omp parallel for #endif for (i=0; i<10; i++) { test_function(); } test_function()里面定义了很多种数据型,例如: test_function() { int a[10]; char ...

by gridbird - C/C++ - 2014-06-04 15:54:49 阅读(5512) 回复(6)

相关讨论

测试了linux下c++和openmp的多线程程序,发现还不如单线程快,各位高手碰到过这个问题吗?代码如下:各位可以测试一下,代码正确。 #include #include #include #include #include #include #include #include #include using namespace std; #define CLOCK_TICKS 100 void show_cpu_time(tms &CPU_begin, tms &CPU_end); int main(int...

by gridbird - C/C++ - 2010-03-04 10:10:10 阅读(6600) 回复(14)

大侠: 请问,能否利用openmp在多核心系统上将一个线程运行在指定的CPU上? 谢谢

by lry_wh - C/C++ - 2005-12-01 11:32:50 阅读(1470) 回复(1)

第一次用openmp 做个并行多线程编程。 #include #include #include #include #include #include #include typedef struct barrel {     char str[8];     struct barrel * next; }barrel_t; barrel_t* B[96]; barrel_t* init_barrel() {     barrel_t *head;    &nbs...

by xp5211314 - C/C++ - 2009-04-16 09:30:18 阅读(1932) 回复(5)

在下想学学openmp内存共享并行编程,但是不知怎么开始,请大侠教之!!!

by ruanxwei - C/C++ - 2005-03-16 23:27:37 阅读(926) 回复(0)

共享内存的系统中用openmp很方便,不知道目前工程中使用得多不?:em03:

by scutan - C/C++ - 2009-07-21 13:40:45 阅读(1382) 回复(2)

openmp的一个程序,刚开始编译不通过,然后改了一下栈空间大小: ulimit -s 10000000 . 程序编译通过, 但是运行出错 libgomp: Thread creation failed: Cannot allocate memory ,即使一个很小的测试程序也出这样的错误。然后把栈空间改小,编译通过的程序就会出现段错误。请高手指点一下了。

by gridbird - C/C++ - 2009-04-30 08:40:32 阅读(1824) 回复(0)

openmp编程中, #pragma omp parallel for private()中可以指定数组吗? 如果我指定#pragma omp parallel for private(a); a为一数组: int a[20]; 如果多个进程的话,是不是需要占用多倍的a数组的内存,private只是说是变量的副本,副本的意思是不是每个进程都会有一个a数组的内存? private的用法和在程序中定义: int a[进程数][20] 到底有什么区别? 多谢高手指点!

by gridbird - C/C++ - 2011-02-23 16:22:41 阅读(2676) 回复(1)

我的CPU的信息如下: Intel(R) Pentium(R) Dual CPU E2160 @ 1.80GHz 1.80GHz 我在网上找到的这段代码,来执行的 #include #include #include void test() {     int a = 0;     clock_t t1 = clock();     for (int i = 0; i < 100000000; i++)     {         a = i+1; ...

by GodPig - C/C++ - 2009-08-13 08:58:02 阅读(1421) 回复(3)

openmp的问题 编译运行一个简单的测试程序使用了 #pragma omp parallel for 能够运行 但是没有omp.h,没法使用函数怎么办? 直接从别人那里考一个omp.h能行么? google了半天,没找到解决方法,哪位帮帮忙,多谢

by KOFKS - C/C++ - 2009-05-19 14:15:40 阅读(6826) 回复(2)

我的开发平台是VC2008 express,编译器支持openmp,但是没有相关的头文件与库文件 哪位好心穿三个文件上来 omp.h VCOMP.lib VCOMP.dll

by reiase - C/C++ - 2008-09-16 10:09:45 阅读(2407) 回复(5)