ubuntu14.04下的openmp支持

2017/8/29 11:32

1、经典源码(helloworld.c):Hello World!

#include <stdio.h>

//#include <omp.h>

int main(int argc,char* argv[])

{

#pragma omp parallel

printf( "Hello World!\n");

return 0;

}

(编译时不加并行参数:-fopenmp)

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ gcc helloworld.c -o helloworld

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ ./helloworld

Hello World!

(编译时加并行参数:-fopenmp)

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ gcc helloworld.c -o helloworld -fopenmp

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ ./helloworld

Hello World!

Hello World!

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

2、openmp经典:对for的支持:

#include <stdio.h>

//#include <omp.h>

int main(int argc,char* argv[])

{

int i;

#pragma omp parallel for

for (i = 0; i < 10; i++ )

{

printf("i = %d\n",i);

}

return 0;

}

(编译时不加并行参数:-fopenmp)

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ gcc for_openmp.c -o for_openmp

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ ./for_openmp

i = 0

i = 1

i = 2

i = 3

i = 4

i = 5

i = 6

i = 7

i = 8

i = 9

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

(编译时加并行参数:-fopenmp)

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ gcc for_openmp.c -o for_openmp -fopenmp

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ ./for_openmp

i = 6

i = 4

i = 5

i = 8

i = 0

i = 1

i = 7

i = 9

i = 2

i = 3

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ i = 3

i = 1

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ i = 1

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

连续执行3次,每次的执行结果都不一样!

环境变量配置:

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ gcc -v

Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper

Target: x86_64-linux-gnu

Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu

Thread model: posix

gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ g++ -v

Using built-in specs.

COLLECT_GCC=g++

COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper

Target: x86_64-linux-gnu

Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu

Thread model: posix

gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

电脑的硬件配置:神舟(HASEE) K580D-i7 D1 15.6英寸笔记本(i7-4710MQ 4G 1TB GT840M 2G独显 D刻 1080P IPS屏)铁灰

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ grep "model name" /proc/cpuinfo |awk -F ':' '{print $NF}'

Intel(R) Core(TM) i7-4710MQ cpu @ 2.50GHz

Intel(R) Core(TM) i7-4710MQ cpu @ 2.50GHz

Intel(R) Core(TM) i7-4710MQ cpu @ 2.50GHz

Intel(R) Core(TM) i7-4710MQ cpu @ 2.50GHz

Intel(R) Core(TM) i7-4710MQ cpu @ 2.50GHz

Intel(R) Core(TM) i7-4710MQ cpu @ 2.50GHz

Intel(R) Core(TM) i7-4710MQ cpu @ 2.50GHz

Intel(R) Core(TM) i7-4710MQ cpu @ 2.50GHz

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ lscpu |grep "cpu socket" |awk '{print $NF}' 或 lscpu |grep "Socket" |awk '{print $NF}'

awk: 致命错误: 无法以读模式打开文件“或”(没有那个文件或目录)

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ lscpu |grep "cpu socket" |awk '{print $NF}'

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ lscpu |grep "Socket" |awk '{print $NF}'

1

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$ lscpu |grep "Core(s) per socket" |awk '{print $NF}'

4

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

rootroot@rootroot-E400:~/wyb/ubuntu_hex/openmp$

http://blog.csdn.net/suchto/article/details/46330235/

Ubuntu下查看cpu、内存和硬盘详细信息的几个命令

cpu:

型号:grep "model name" /proc/cpuinfo |awk -F ':' '{print $NF}'

数量:lscpu |grep "cpu socket" |awk '{print $NF}' 或 lscpu |grep "Socket" |awk '{print $NF}'

每个cpu的核数:lscpu |grep "Core(s) per socket" |awk '{print $NF}'

参考资料:

https://www.ibm.com/developerworks/cn/aix/library/au-aix-openmp-framework/

通过 GCC 学习 OpenMP 框架

http://blog.csdn.net/qq_20198487/article/details/51626464

Linux环境下的OpenMP多线程编程

http://linux.chinaunix.net/techdoc/beginner/2009/06/10/1117627.shtml

关于linux下的openmp编程基础

ubuntu14.04下的openmp支持的更多相关文章

  1. ios – 将参数传递给drawRect

    我有几个UIView类都绘制相同的东西,但使用不同的颜色和alpha设置.我试图传递参数,但无法弄清楚如何获得我需要的drawRect部分.我画的是这样的:我的DrawHexBlue类是这样的:}我为我需要的每种新颜色和新的alpha值创建了一个新类.当然必须有一个更好的方法来使用一个类,只需更改参数/值……?解决方法创建单个UIView子类并添加属性:然后在drawRect:您可以访问此属性:您可以在创建视图时在视图上进行设置:

  2. iOS BLE蓝牙 – 发送/接收HEX数据

    我正在创建一个应该连接到自定义BLE设备的iOS应用程序.我需要iOS应用程序发送2个HEX命令,一个用于启用设备的一部分,另一个用于请求数据.iOS中是否有任何方式发送/接收自定义HEX数据,除了使用服务&特点?

  3. xcode – OpenMP for Snow Leopard的链接库?

    或者我应该说,openMP的链接库的名称是什么?它是dylib,框架还是什么?或者我是否需要先从某个地方获取它?解决方法如果有人想知道如何在XCode4中编译它,我也必须启用OpenMP支持.我通过单击项目启用了OpenMP支持,然后在“构建选项”下,我将“启用OpenMP支持”从“否”更改为“是”.此外,我不得不将编译器版本从“LLVM2.0”更改为“GCC4.2”或“LLVMGCC4.2”.否则,编译器找不到“omp.h”.

  4. Swift String to UIColor (支持3,4,6,8长度的16进制颜色值)

    importUIKitextensionUIColor{publicconvenienceinit(rgba:String){varred:CGFloat=0.0vargreen:CGFloat0varblue:CGFloat0varalpha:CGFloat10ifrgba.hasPrefix("#"){letindex=advance(rgba.startIndex,1)lethex=rgba

  5. Project Perfect让Swift在服务器端跑起来-在Linux上创建你的Perfect项目(三)

    前两篇,分别讲述了入门和在Linux下部署,现在得说说如何在Linux下开发了。在Linux下开发,相对比在Mac下开发更灵活。我们先来看看构建基于Perfect的网站服务的编译方式如图通过引用基础库PerfectLib和数据链接,中间件模块创建你的网页文件,并用makefile打包生成你的网站动态库。所以如果你只是在Linux下构建项目,你只需要先创建好你的Handlers.swift即可。根据上面的方式我们开始在Linux下创建我们的Perfect项目。这里我在Perfect文件夹创建了一个Demo文

  6. 使用 Swift 语言编写 Android 应用入门

    Swift标准库可以编译安卓armv7的内核,这使得可以在安卓移动设备上执行Swift语句代码。做梦,虽然Swift编译器可以胜任在安卓设备上编译Swift代码并运行。这需要的不仅仅是用Swift标准库编写一个APP,更多的是你需要一些框架来搭建你的应用用户界面,以上这些Swift标准库不能提供。简单来说,构建在安卓设备上使用的Swiftstdlib需要libiconv和libicu。通过命令行执行以下命令:gitclonegit@github.com:SwiftAndroid/libiconv-libi

  7. Project Perfect让Swift在服务器端跑起来-Hi Linux(二)

    开篇写了一个简单的入门,今天想说说怎么让Perfect项目在Linux上运行。Swift开源后,苹果让Swift不仅在OSX/iOS上跑,更让Swift在Linux/Windows上跑。作为服务端的Perfect框架+RemObjectSilver,让Swift成为了一个全栈语言。Perfect由于是服务端的,让Perfect在Linux上跑是必然的事情。从第一篇文章中我们可以了解到Perfect由PerfectLib和PerfectServer组成。

  8. Project Perfect让Swift在服务器端跑起来-在Linux上创建你的Perfect项

    前两篇,分别讲述了入门和在Linux下部署,现在得说说如何在Linux下开发了。在Linux下开发,相对比在Mac下开发更灵活。我们先来看看构建基于Perfect的网站服务的编译方式如图通过引用基础库PerfectLib和数据链接,中间件模块创建你的网页文件,并用makefile打包生成你的网站动态库。所以如果你只是在Linux下构建项目,你只需要先创建好你的Handlers.Swift即可。根据上面的方式我们开始在Linux下创建我们的Perfect项目。

  9. Swift 解析16进制颜色

    Swift版解析16进制颜色使用方式

  10. Swift for OS X编译Linux?

    我对其他平台上Swift的构建过程感到困惑.Swift是否允许我在OSX上构建Linux项目,或者我是否需要在Linux上专门使用Swift来构建我计划在那里使用的任何东西?我查看了documentation,但这个主题并不是很清楚……

随机推荐

  1. crontab发送一个月份的电子邮件

    ubuntu14.04邮件服务器:Postfixroot收到来自crontab的十几封电子邮件.这些邮件包含PHP警告.>我已经解决了这些警告的原因.>我已修复每个cronjobs不发送电子邮件(输出发送到>/dev/null2>&1)>我删除了之前的所有电子邮件/var/mail/root/var/spool/mail/root但我仍然每小时收到十几封电子邮件.这些电子邮件来自cronjobs,

  2. 模拟两个ubuntu服务器计算机之间的慢速连接

    我想模拟以下场景:假设我有4台ubuntu服务器机器A,B,C和D.我想在机器A和机器C之间减少20%的网络带宽,在A和B之间减少10%.使用网络模拟/限制工具来做到这一点?

  3. ubuntu-12.04 – 如何在ubuntu 12.04中卸载从源安装的redis?

    我从源代码在Ubuntu12.04上安装了redis-server.但在某些时候它无法完全安装,最后一次makeinstallcmd失败.然后我刚刚通过apt包安装.现在我很困惑哪个安装正在运行哪个conf文件?实际上我想卸载/删除通过源安装的所有内容,只是想安装一个包.转到源代码树并尝试以下命令:如果这不起作用,您可以列出软件自行安装所需的步骤:

  4. ubuntu – “apt-get source”无法找到包但“apt-get install”和“apt-get cache”可以找到它

    我正在尝试下载软件包的源代码,但是当我运行时它无法找到.但是当我运行apt-cache搜索squid3时,它会找到它.它也适用于apt-getinstallsquid3.我使用的是Ubuntu11.04服务器,这是我的/etc/apt/sources.list我已经多次更新了.我尝试了很多不同的debs,并没有发现任何其他地方的错误.这里的问题是你的二进制包(deb)与你的源包(deb-src)不

  5. ubuntu – 有没有办法检测nginx何时完成正常关闭?

    &&touchrestarted),因为即使Nginx没有完成其关闭,touch命令也会立即执行.有没有好办法呢?这样的事情怎么样?因此,pgrep将查找任何Nginx进程,而while循环将让它坐在那里直到它们全部消失.你可以改变一些有用的东西,比如睡1;/etc/init.d/Nginx停止,以便它会休眠一秒钟,然后尝试使用init.d脚本停止Nginx.你也可以在某处放置一个计数器,这样你就可以在需要太长时间时发出轰击信号.

  6. ubuntu – 如何将所有外发电子邮件从postfix重定向到单个地址进行测试

    我正在为基于Web的应用程序设置测试服务器,该应用程序发送一些电子邮件通知.有时候测试是使用真实的客户数据进行的,因此我需要保证服务器在我们测试时无法向真实客户发送电子邮件.我想要的是配置postfix,以便它接收任何外发电子邮件并将其重定向到一个电子邮件地址,而不是传递到真正的目的地.我正在运行ubuntu服务器9.10.先感谢您设置本地用户以接收所有被困邮件:你需要在main.cf中添加:然后

  7. ubuntu – vagrant无法连接到虚拟框

    当我使用基本的Vagrantfile,只配置了两条线:我看到我的虚拟框打开,但是我的流氓日志多次显示此行直到超时:然后,超时后的一段时间,虚拟框框终于要求我登录,但是太久了!所以我用流氓/流氓记录.然后在我的物理机器上,如果我“流氓ssh”.没有事情发生,直到:怎么了?

  8. ubuntu – Nginx – 转发HTTP AUTH – 用户?

    我和Nginx和Jenkins有些麻烦.我尝试使用Nginx作为Jenkins实例的反向代理,使用HTTP基本身份验证.它到目前为止工作,但我不知道如何传递带有AUTH用户名的标头?}尝试将此指令添加到您的位置块

  9. Debian / Ubuntu – 删除后如何恢复/ var / cache / apt结构?

    我在ubuntu服务器上的空间不足,所以我做了这个命令以节省空间但是现在在尝试使用apt时,我会收到以下错误:等等显然我删除了一些目录结构.有没有办法做apt-getrebuild-var-tree或类似的?

  10. 检查ubuntu上安装的rubygems版本?

    如何查看我的ubuntu盒子上安装的rubygems版本?只是一个想法,列出已安装的软件包和grep为ruby或宝石或其他:)dpkg–get-selections

返回
顶部