dw_mult.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef __MULT_H__
  17. #define __MULT_H__
  18. #include <string.h>
  19. #include <math.h>
  20. #include <sys/types.h>
  21. #include <sys/time.h>
  22. #include <pthread.h>
  23. #include <signal.h>
  24. #include <common/blas.h>
  25. #include <common/blas_model.h>
  26. #include <starpu.h>
  27. #ifdef USE_CUDA
  28. #include <cuda.h>
  29. #include <cublas.h>
  30. #endif
  31. #define MAXSLICESX 64
  32. #define MAXSLICESY 64
  33. #define MAXSLICESZ 64
  34. #define BLAS3_FLOP(n1,n2,n3) \
  35. (2*((uint64_t)n1)*((uint64_t)n2)*((uint64_t)n3))
  36. #define BLAS3_LS(n1,n2,n3) \
  37. ((2*(n1)*(n3) + (n1)*(n2) + (n2)*(n3))*sizeof(float))
  38. struct block_conf {
  39. uint32_t m;
  40. uint32_t n;
  41. uint32_t k;
  42. uint32_t pad;
  43. };
  44. #define NITER 100
  45. unsigned niter = NITER;
  46. unsigned nslicesx = 4;
  47. unsigned nslicesy = 4;
  48. unsigned nslicesz = 4;
  49. unsigned xdim = 256;
  50. unsigned ydim = 256;
  51. unsigned zdim = 64;
  52. unsigned norandom = 0;
  53. unsigned pin = 0;
  54. unsigned use_common_model = 0;
  55. /* to compute MFlop/s */
  56. uint64_t flop_cublas = 0;
  57. uint64_t flop_atlas = 0;
  58. /* to compute MB/s (load/store) */
  59. uint64_t ls_cublas = 0;
  60. uint64_t ls_atlas = 0;
  61. struct timeval start;
  62. struct timeval end;
  63. static int taskcounter __attribute__ ((unused));
  64. static struct block_conf conf __attribute__ ((aligned (128)));
  65. #define BLOCKSIZEX (xdim / nslicesx)
  66. #define BLOCKSIZEY (ydim / nslicesy)
  67. #define BLOCKSIZEZ (zdim / nslicesz)
  68. static void parse_args(int argc, char **argv)
  69. {
  70. int i;
  71. for (i = 1; i < argc; i++) {
  72. if (strcmp(argv[i], "-nblocks") == 0) {
  73. char *argptr;
  74. nslicesx = strtol(argv[++i], &argptr, 10);
  75. nslicesy = nslicesx;
  76. nslicesz = nslicesx;
  77. }
  78. if (strcmp(argv[i], "-nblocksx") == 0) {
  79. char *argptr;
  80. nslicesx = strtol(argv[++i], &argptr, 10);
  81. }
  82. if (strcmp(argv[i], "-nblocksy") == 0) {
  83. char *argptr;
  84. nslicesy = strtol(argv[++i], &argptr, 10);
  85. }
  86. if (strcmp(argv[i], "-nblocksz") == 0) {
  87. char *argptr;
  88. nslicesz = strtol(argv[++i], &argptr, 10);
  89. }
  90. if (strcmp(argv[i], "-x") == 0) {
  91. char *argptr;
  92. xdim = strtol(argv[++i], &argptr, 10);
  93. }
  94. if (strcmp(argv[i], "-y") == 0) {
  95. char *argptr;
  96. ydim = strtol(argv[++i], &argptr, 10);
  97. }
  98. if (strcmp(argv[i], "-z") == 0) {
  99. char *argptr;
  100. zdim = strtol(argv[++i], &argptr, 10);
  101. }
  102. if (strcmp(argv[i], "-iter") == 0) {
  103. char *argptr;
  104. niter = strtol(argv[++i], &argptr, 10);
  105. }
  106. if (strcmp(argv[i], "-no-random") == 0) {
  107. norandom = 1;
  108. }
  109. if (strcmp(argv[i], "-pin") == 0) {
  110. pin = 1;
  111. }
  112. if (strcmp(argv[i], "-common-model") == 0) {
  113. use_common_model = 1;
  114. }
  115. }
  116. assert(nslicesx <= MAXSLICESX);
  117. assert(nslicesy <= MAXSLICESY);
  118. assert(nslicesz <= MAXSLICESZ);
  119. }
  120. static void display_memory_consumption(void)
  121. {
  122. fprintf(stderr, "Total memory : %ld MB\n",
  123. (MAXSLICESY*MAXSLICESZ*sizeof(float *)
  124. + MAXSLICESZ*MAXSLICESX*sizeof(float *)
  125. + MAXSLICESY*MAXSLICESX*sizeof(float *)
  126. + MAXSLICESY*MAXSLICESZ*sizeof(starpu_data_handle)
  127. + MAXSLICESZ*MAXSLICESX*sizeof(starpu_data_handle)
  128. + MAXSLICESY*MAXSLICESX*sizeof(starpu_data_handle)
  129. + ydim*zdim*sizeof(float)
  130. + zdim*xdim*sizeof(float)
  131. + ydim*xdim*sizeof(float))/(1024*1024) );
  132. }
  133. #endif // __MULT_H__