Intel Core Duo Intel Compilers 10 x Windows

  • Slides: 30
Download presentation
Intel® Core Duo™ 处理器上使用 Intel Compilers 10. x Windows版本 杨全胜 http: //www. njyangqs. com/

Intel® Core Duo™ 处理器上使用 Intel Compilers 10. x Windows版本 杨全胜 http: //www. njyangqs. com/ 东南大学成贤学院计算机系

多核结构与程序设计 介绍 n 在Microsoft 10. 0中使用Intel Compiler 10. 0 Southeast University 东 南 大

多核结构与程序设计 介绍 n 在Microsoft 10. 0中使用Intel Compiler 10. 0 Southeast University 东 南 大 学 5 http: //www. njyangqs. com/

多核结构与程序设计 介绍 n 在Microsoft IDE中使用Intel Compiler 11. 0 Southeast University 东 南 大 学

多核结构与程序设计 介绍 n 在Microsoft IDE中使用Intel Compiler 11. 0 Southeast University 东 南 大 学 6 http: //www. njyangqs. com/

多核结构与程序设计 编译器开关 n IPO使用: 两阶段处理 Compiling Pass 1 Windows* icl -c /Qipo main. c

多核结构与程序设计 编译器开关 n IPO使用: 两阶段处理 Compiling Pass 1 Windows* icl -c /Qipo main. c func 1. c func 2. c Linux* icc -c -ipo main. c func 1. c func 2. c Mac* icc -c -ipo main. c func 1. c func 2. c virtual . o Pass 2 executable Southeast University 东 南 大 学 Linking Windows* icl /Qipo main. o func 1. o func 2. o Linux* icc -ipo main. o func 1. o func 2. o Mac* icc -ipo main. o func 1. o func 2. o 10 http: //www. njyangqs. com/

多核结构与程序设计 编译器开关 n PGO: 三阶段处理 Step 1 编译指令 (Mac*/Linux*) icc -prof_gen[x] prog. c -prof_gen[x]

多核结构与程序设计 编译器开关 n PGO: 三阶段处理 Step 1 编译指令 (Mac*/Linux*) icc -prof_gen[x] prog. c -prof_gen[x] (Windows*) icl -Qprof_gen[x] prog. c -Qprof_gen[x] 可执行的指令 Step 2 执行指令 DYN文件包含动态信 息: . dyn 用典型的数据集来执行程序 Step 3 合并DYN概要文件: . dpi, 如果你不希望旧的信息被包 含进去,就删除旧的dyn 反馈给编译 (Mac/Linux) icc -prof_use prog. c -prof_use (Windows) icl -Qprof_use prog. c -Qprof_use Southeast University 东 南 大 学 12 http: //www. njyangqs. com/

多核结构与程序设计 双核 n Open. MP*线程化技术 u 基于Pragma的并行化技术 u 使用方法: F Open. MP开关: -openmp :

多核结构与程序设计 双核 n Open. MP*线程化技术 u 基于Pragma的并行化技术 u 使用方法: F Open. MP开关: -openmp : /Qopenmp F Open. MP报告: -openmp-report : /Qopenmpreport #pragma omp parallel for (i=0; i<MAX; i++) C[i]= c*A[i] + B[i]; Southeast University 东 南 大 学 15 http: //www. njyangqs. com/

多核结构与程序设计 双核 n Open. MP*线程化技术 u Intel编译器的 作队列扩展 F 创建任务队列…继续 作… • 递归函数 •

多核结构与程序设计 双核 n Open. MP*线程化技术 u Intel编译器的 作队列扩展 F 创建任务队列…继续 作… • 递归函数 • 链表等 #pragma intel omp parallel taskq shared(p) { while (p != NULL) { #pragma intel omp task captureprivate(p) do_work 1(p); p = p->next; } } Southeast University 东 南 大 学 16 http: //www. njyangqs. com/

多核结构与程序设计 双核 n 并行诊断 u Intel Thread Checker中用源指令 F 允许线程检查器诊断线程化的正确性错误 F 要使用tcheck /Qtcheck 必须安装Intel

多核结构与程序设计 双核 n 并行诊断 u Intel Thread Checker中用源指令 F 允许线程检查器诊断线程化的正确性错误 F 要使用tcheck /Qtcheck 必须安装Intel Thread Checker F 看有关线程检查器的文档 F http: //www. intel. com/support/performanceto ols/sb/CS-009681. htm Southeast University 东 南 大 学 17 http: //www. njyangqs. com/

多核结构与程序设计 向量化 4 x doubles 8 x floats 2 x dqword 2 x doubles

多核结构与程序设计 向量化 4 x doubles 8 x floats 2 x dqword 2 x doubles 4 x floats 1 x dqword 16 x bytes AVX*** SSE 2 SSE 3 SSE 4 SSE** MMX* 8 x words 4 x dwords 2 x qwords 8 x bytes 4 x words 2 x dwords 1 x qwords * MMX使用的是 64位的 x 87 浮点寄存器作为MMX寄存器; **SSE, SSE 2, SSE 3和 SSE 4 使用了新的128位的XMM 寄存器;也可用MMX寄存器 19 http: //www. njyangqs. com/ 东***AVX使用了新的256位的YMM 寄存器;也可用XMM寄存器,但是不使用MMX寄存器 南 大 学 Southeast University

多核结构与程序设计 向量化 n SSE 3指令 FISTTP 浮点到整数的转换 复数运算 视频编码 ADDSUBPD, ADDSUBPS, MOVDDUP, MOVSHDUP, MOVSLDUP

多核结构与程序设计 向量化 n SSE 3指令 FISTTP 浮点到整数的转换 复数运算 视频编码 ADDSUBPD, ADDSUBPS, MOVDDUP, MOVSHDUP, MOVSLDUP LDDQU SIMD浮点使用AOS 格式 HADDPD, HSUBPD HADDPS, HSUBPS 线程同步 MONITOR, MWAIT * 对复数和向量化都有好处 Southeast University 东 南 大 学 20 http: //www. njyangqs. com/

多核结构与程序设计 向量化 n 使用SSE 3 由下面的情况转成… for (i=0; i<=MAX; i++) c[i]=a[i]+b[i]; Southeast University 东

多核结构与程序设计 向量化 n 使用SSE 3 由下面的情况转成… for (i=0; i<=MAX; i++) c[i]=a[i]+b[i]; Southeast University 东 南 大 学 A[1] A[0] + not used + B[1] B[0] not used + 128 -bit Registers not used C[0] C[1] not used 21 http: //www. njyangqs. com/

多核结构与程序设计 向量化 n … 这样的情况 for (i=0; i<=MAX; i++) c[i]=a[i]+b[i]; Southeast University 东 南

多核结构与程序设计 向量化 n … 这样的情况 for (i=0; i<=MAX; i++) c[i]=a[i]+b[i]; Southeast University 东 南 大 学 A[3] + A[2] + A[1] + B[3] B[2] B[1] A[0] + 128 -bit Registers B[0] C[3] C[2] C[1] C[0] 22 http: //www. njyangqs. com/

多核结构与程序设计 向量化 n 为什么循环不能向量化 u “包含非向量化语句” for (i=1; i<nx; i++) { B[i] = func(A[i]);

多核结构与程序设计 向量化 n 为什么循环不能向量化 u “包含非向量化语句” for (i=1; i<nx; i++) { B[i] = func(A[i]); } Southeast University 东 南 大 学 A[3] func A[2] func A[1] func B[3] B[2] B[1] 30 A[0] func 128 -bit Registers B[0] http: //www. njyangqs. com/