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

Function main

code/Chapter8/8-12.c:22–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

matrixmulti_1Function · 0.85

Tested by

no test coverage detected