资源简介
Open MP是关于并行编程方面的文档包括代码
代码片段和文件信息
//Simple minded matrix multiply
#include
#include
#include
#include “mkl.h“
void print_arr(int N char * name double* array);
void init_arr(int N double* a);
void Dgemm_multiply(double* adouble* bdouble* c int N);
void Dgemv_multiply(double* adouble* bdouble* c int N);
void Ddot_Multiply(double* adouble* bdouble* c int N);
void roll_your_own_multiply(double* adouble* bdouble* c int N);
int main(int argc char* argv[])
{
clock_t start stop;
int i j;
int N;
double* a;
double* b;
double* c;
if(argc < 2)
{
printf(“Enter matrix size N=“);
//please enter small number first to ensure that the
//multiplication is correct! and then you may enter
//a “reasonably“ large number say like 500 or even 1000
scanf(“%d“&N);
}
else
{
N = atoi(argv[1]);
}
a=(double*) malloc( sizeof(double)*N*N );
b=(double*) malloc( sizeof(double)*N*N );
c=(double*) malloc( sizeof(double)*N*N );
init_arr(Na);
init_arr(Nb);
//DGEMM Multiply
start = clock();
Dgemm_multiply(abcN);
stop = clock();
printf(“Dgemm_multiply(). Elapsed time = %g seconds\n“
((double)(stop - start)) / CLOCKS_PER_SEC);
//print simple test case of data to be sure multiplication is correct
if (N < 7) {
print_arr(N“a“ a);
print_arr(N“b“ b);
print_arr(N“c“ c);
}
free(a);
free(b);
free(c);
return 0;
}
//Brute force way of matrix multiply
void roll_your_own_multiply(double* adouble* bdouble* c int N)
{
int i j k;
for (i = 0; i < N; i++) {
for (j=0; j for (k=0; k c[N*i+j] += a[N*i+k] * b[N*k+j];
}
}
}
}
//The ddot way to matrix multiply
void Ddot_Multiply(double* adouble* bdouble* c int N)
{
int i j;
int incx = 1;
int incy = N;
for (i = 0; i < N; i++) {
for (j=0; j c[N*i+j] = cblas_ddot(N&a[N*i]incx&b[j]incy);
}
}
}
//DGEMV way of matrix multiply
void Dgemv_multiply(double* adouble* bdouble* c int N)
{
int i;
double alpha = 1.0 beta = 0.;
int incx = 1;
int incy = N;
for (i = 0; i < N; i++) {
cblas_dgemv(CblasRowMajorCblasNoTransNNalphaaN&b[i]Nbeta&c[i]N);
}
}
//DGEMM way. The PREFERED way especially for large matrices
void Dgemm_multiply(double* adouble* bdouble* c int N)
{
int i;
double alpha = 1.0 beta = 0.;
int incx = 1;
int incy = N;
cblas_dgemm(CblasRowMajorCblasNoTransCblasNoTransNNNalphabNaNbetacN);
}
//initialize array with random data
void init_arr(int N double* a)
{
int ij;
for (i=0; i< N;i++) {
for (j=0; j a[i*N+j] = (i+j+1)%10; //keep all entries less than 10. pleasing to the eye!
}
}
}
//print array to std out
void print_arr(int N char * name double* array)
{
int ij;
printf(“\n%s\n“name);
for (i=0;i for (j=0;j printf(“%g\t“array[N*i+j]);
}
printf(“\n“);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 77824 2008-10-09 02:25 Lab2\Lab2.doc
文件 323 2008-10-04 15:05 Lab2\MKL_Overview\DGEMM\makefile
文件 770048 2008-10-04 15:05 Lab2\MKL_Overview\DGEMM\matrix.exe
文件 3008 2008-10-04 10:00 Lab2\MKL_Overview\DGEMM\mkl_dgemm.c
文件 4524 2008-10-04 10:00 Lab2\MKL_Overview\DGEMM\mkl_lab.c
文件 4854 2008-10-04 10:00 Lab2\MKL_Overview\DGEMM\mkl_lab_solution.c
文件 9142 2008-10-04 15:05 Lab2\MKL_Overview\DGEMM\mkl_lab_solution.obj
文件 1000 2008-10-04 09:00 Lab2\omp-demo\badloop.c
文件 445 2008-10-04 09:00 Lab2\omp-demo\cri.c
文件 315392 2008-10-06 23:28 Lab2\omp-demo\cri.exe
文件 2780 2008-10-06 23:28 Lab2\omp-demo\cri.obj
文件 228 2008-10-04 09:00 Lab2\omp-demo\critical.c
文件 1150 2008-10-04 09:00 Lab2\omp-demo\dis-err.c
文件 1646 2008-10-04 09:00 Lab2\omp-demo\dis-ok.c
文件 1584 2008-10-04 09:00 Lab2\omp-demo\dis-ok1.c
文件 1061 2008-10-04 09:00 Lab2\omp-demo\loopA1.c
文件 1290 2008-10-04 09:00 Lab2\omp-demo\loopA2.c
文件 289 2008-10-04 09:00 Lab2\omp-demo\master.c
文件 489 2008-10-04 09:00 Lab2\omp-demo\pfor-no-schedule.c
文件 495 2008-10-04 09:00 Lab2\omp-demo\pfor.c
文件 541 2008-10-04 09:00 Lab2\omp-demo\pi01.c
文件 532 2008-10-04 09:00 Lab2\omp-demo\pi02.c
文件 579 2008-10-04 09:00 Lab2\omp-demo\pi03.c
文件 419 2008-10-04 09:00 Lab2\omp-demo\pi04.c
文件 422 2008-10-04 09:00 Lab2\omp-demo\private.c
文件 379 2008-10-04 09:00 Lab2\omp-demo\reduction.c
文件 644 2008-10-04 09:00 Lab2\omp-demo\section.c
文件 330 2008-10-04 09:00 Lab2\omp-demo\single.c
文件 339 2008-10-04 09:00 Lab2\omp-demo\threadprivate.c
文件 154 2008-10-04 09:34 Lab2\OpenMP\HelloWorlds\HelloWorlds.c
............此处省略37个文件信息
相关资源
- CANopen使用手册_埃斯顿
- OpenGL参考手册
- 引力波是玻色-爱因斯坦凝聚物暗物质
- Qt Creator opengl实现四元数鼠标控制轨迹
- 使用OpenFileDialog打开文件对话框.rar
- Openssl给文件传输加密
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 基于OpenCV的数字识别468815
- 使用opencv去掉二值化图像中黑色面积
- openssl 简介(中文)
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
- 计算机图形学(openGL)代码
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- opencv环境配置
- 探索LHC耦合中的CP振动效应
- 复合共振的行为打破了轻质风味的普
- 重建希格斯产生的共振tau对中的半不
- 中微子质量和暗物质的模型,具有大
- 外来轻质风味违反希格斯衰变
- Zee模型的全参数扫描:探索希格斯轻
- B介子的重生和暗物质
评论
共有 条评论