MCPcopy Create free account
hub / github.com/AdvancedCompiler/AdvancedCompiler / main

Function main

code/Chapter8/8-11.c:19–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 }
18}
19int main()
20{
21 int n, i, j;
22 float ** x, ** y, ** z;
23 n = 1024;
24 double Total_time;
25 clock_t start, end;
26 printf("测试矩阵维数 n=%d\n",n);
27 y = (float**)malloc(n * sizeof(float*));
28 z = (float**)malloc(n * sizeof(float*));
29 x = (float**)malloc(n * sizeof(float*));
30 for (i = 0; i < n; i++)
31 {
32 y[i] = (float*)malloc(n * sizeof(float));
33 z[i] = (float*)malloc(n * sizeof(float));
34 x[i] = (float*)malloc(n * sizeof(float));
35 }
36 for (i = 0; i < n; i++)
37 {
38 for (j = 0; j < n; j++)
39 {
40 y[i][j] = rand() % 10;
41 z[i][j] = rand() % 10;
42 x[i][j] = 0;
43 }
44 }
45 start = clock();
46 matrixmulti(n, x, y, z);
47 end = clock();
48 Total_time=(double)(end - start) / CLOCKS_PER_SEC;
49 printf("1024*1024的矩阵乘缓存分块优化前:%lf秒\n",Total_time);
50 for(i=0;i<n;i++){
51 free(y[i]);
52 free(z[i]);
53 free(x[i]);
54 }
55 free(y);
56 free(z);
57 free(x);
58 return 0;
59}

Callers

nothing calls this directly

Calls 1

matrixmultiFunction · 0.70

Tested by

no test coverage detected