ctest860.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/time.h>
  4. void kernel_cpu(int *A0,int *A1,int *A2,int *A3,int *A4,int *A5,int *A6,int *A7,int *A8,float *B0,float *B1,float *B2,float *B3,int N){
  5. for(int i=0;i<N;i++){
  6. A0[i] = A7[i]-A2[i];
  7. A1[i] = A7[i]/A8[i]+A2[i]*A7[i];
  8. B0[i] = B2[i];
  9. B1[i] = B2[i]/B3[i]*B3[i]/B2[i];
  10. }
  11. }
  12. int main(int argc,char **argv) {
  13. int size=934520;
  14. int intBytes = size*sizeof(int);
  15. int floatBytes = size*sizeof(float);
  16. int *A0;
  17. A0 = (int *)malloc(intBytes);
  18. int *A1;
  19. A1 = (int *)malloc(intBytes);
  20. int *A2;
  21. A2 = (int *)malloc(intBytes);
  22. int *A3;
  23. A3 = (int *)malloc(intBytes);
  24. int *A4;
  25. A4 = (int *)malloc(intBytes);
  26. int *A5;
  27. A5 = (int *)malloc(intBytes);
  28. int *A6;
  29. A6 = (int *)malloc(intBytes);
  30. int *A7;
  31. A7 = (int *)malloc(intBytes);
  32. int *A8;
  33. A8 = (int *)malloc(intBytes);
  34. float *B0;
  35. B0 = (float *)malloc(floatBytes);
  36. float *B1;
  37. B1 = (float *)malloc(floatBytes);
  38. float *B2;
  39. B2 = (float *)malloc(floatBytes);
  40. float *B3;
  41. B3 = (float *)malloc(floatBytes);
  42. for(int i=0;i<934520;i++){
  43. A0[i] = 34+i+1;
  44. A1[i] = 27+i+1;
  45. A2[i] = 43*i+1;
  46. A3[i] = 49+i+1;
  47. A4[i] = 76+i+1;
  48. A5[i] = 40+i+1;
  49. A6[i] = 73*i+1;
  50. A7[i] = 44*i+1;
  51. A8[i] = 49*i+1;
  52. B0[i] = 6.14892620047+i+1;
  53. B1[i] = 65.7391379719*i+1;
  54. B2[i] = 1.2086797096+i+1;
  55. B3[i] = 33.3153585702+i+1;
  56. }
  57. struct timeval time0,time1;
  58. gettimeofday(&time0,NULL);
  59. FILE *file_for_block_of_interest = fopen("./profile_in_block.txt","w");
  60. if(file_for_block_of_interest) {
  61. char Buf[2] = "1";
  62. fwrite(Buf, 1, 1, file_for_block_of_interest);
  63. fclose(file_for_block_of_interest);}
  64. kernel_cpu(A0,A1,A2,A3,A4,A5,A6,A7,A8,B0,B1,B2,B3,934520);
  65. file_for_block_of_interest = fopen("./profile_in_block.txt","w");
  66. if(file_for_block_of_interest) {
  67. char Buf[2] = "0";
  68. fwrite(Buf, 1, 1, file_for_block_of_interest);
  69. fclose(file_for_block_of_interest);}
  70. gettimeofday(&time1,NULL);
  71. double totaltime10 = (time1.tv_sec*1000000.0 + time1.tv_usec) - (time0.tv_sec*1000000.0 + time0.tv_usec);
  72. fprintf(stderr, "CPU time: %lf msecs ", (totaltime10)/1000.0F);
  73. free(A0);
  74. free(A1);
  75. free(A2);
  76. free(A3);
  77. free(A4);
  78. free(A5);
  79. free(A6);
  80. free(A7);
  81. free(A8);
  82. free(B0);
  83. free(B1);
  84. free(B2);
  85. free(B3);
  86. printf("\n");return 0; }