包括各种执行时间截图和表格
return 0; }
串行计算的矩阵乘法源代码:DenseMulMatrixSerial.c #include <stdio.h> #include <stdlib.h> #include <time.h> #define Length 1000
int *A,*B,*C; int i,j,k;
clock_t startTime, endTime; double totalTime;
void InitMatrix(int *M,int *N,int len);//实现部分见上面 void del(){ free(A); free(B); free(C); }
int main() {
A = (int *)malloc(sizeof(int)*Length*Length); B = (int *)malloc(sizeof(int)*Length*Length); C = (int *)malloc(sizeof(int)*Length*Length); InitMatrix(A,B,Length); startTime = clock();
for(i = 0; i < Length; i ++) {
for(j = 0; j < Length; j ++) {
C[i * Length + j] = 0;
for (k = 0; k < Length; ++k) { C[i * Length + j] += A[i * Length + k] *
B[k * Length + j];
} } }//for
endTime = clock(); totalTime = (double)(endTime - startTime) / CLOCKS_PER_SEC; printf("串行稠密矩阵乘法过程总共花的时间:%.4fs\n",
totalTime); del();
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库并行处理实验报告:用MPI实现的矩阵乘法的加速比分析(6)在线全文阅读。
相关推荐: