ctest58.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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,int N){
  5. for(int i=0;i<N;i++){
  6. A0[i] = A3[i];
  7. A1[i] = A3[i]/A5[i]*A5[i];
  8. A2[i] = A7[i];
  9. B0[i] = B0[i];
  10. }
  11. }
  12. int main(int argc,char **argv) {
  13. int size=288075;
  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. for(int i=0;i<288075;i++){
  37. A0[i] = 22*i+1;
  38. A1[i] = 87*i+1;
  39. A2[i] = 73+i+1;
  40. A3[i] = 28*i+1;
  41. A4[i] = 37+i+1;
  42. A5[i] = 47+i+1;
  43. A6[i] = 0+i+1;
  44. A7[i] = 86+i+1;
  45. A8[i] = 67*i+1;
  46. B0[i] = 85.1531982805+i+1;
  47. }
  48. struct timeval time0,time1;
  49. gettimeofday(&time0,NULL);
  50. FILE *file_for_block_of_interest = fopen("./profile_in_block.txt","w");
  51. if(file_for_block_of_interest) {
  52. char Buf[2] = "1";
  53. fwrite(Buf, 1, 1, file_for_block_of_interest);
  54. fclose(file_for_block_of_interest);}
  55. kernel_cpu(A0,A1,A2,A3,A4,A5,A6,A7,A8,B0,288075);
  56. file_for_block_of_interest = fopen("./profile_in_block.txt","w");
  57. if(file_for_block_of_interest) {
  58. char Buf[2] = "0";
  59. fwrite(Buf, 1, 1, file_for_block_of_interest);
  60. fclose(file_for_block_of_interest);}
  61. gettimeofday(&time1,NULL);
  62. double totaltime10 = (time1.tv_sec*1000000.0 + time1.tv_usec) - (time0.tv_sec*1000000.0 + time0.tv_usec);
  63. fprintf(stderr, "CPU time: %lf msecs ", (totaltime10)/1000.0F);
  64. free(A0);
  65. free(A1);
  66. free(A2);
  67. free(A3);
  68. free(A4);
  69. free(A5);
  70. free(A6);
  71. free(A7);
  72. free(A8);
  73. free(B0);
  74. printf("\n");return 0; }