dw_mult.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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_config.h>
  27. #include <starpu.h>
  28. #ifdef USE_CUDA
  29. #include <cuda.h>
  30. #include <cublas.h>
  31. #endif
  32. #define MAXSLICESX 32
  33. #define MAXSLICESY 32
  34. #define MAXSLICESZ 32
  35. #define BLAS3_FLOP(n1,n2,n3) \
  36. (2*((uint64_t)n1)*((uint64_t)n2)*((uint64_t)n3))
  37. #define BLAS3_LS(n1,n2,n3) \
  38. ((2*(n1)*(n3) + (n1)*(n2) + (n2)*(n3))*sizeof(float))
  39. struct block_conf {
  40. uint32_t m;
  41. uint32_t n;
  42. uint32_t k;
  43. uint32_t pad;
  44. };
  45. #define NITER 100
  46. unsigned niter = NITER;
  47. unsigned nslicesx = 4;
  48. unsigned nslicesy = 4;
  49. unsigned nslicesz = 4;
  50. unsigned xdim = 256;
  51. unsigned ydim = 256;
  52. unsigned zdim = 64;
  53. unsigned norandom = 0;
  54. unsigned pin = 0;
  55. unsigned use_common_model = 0;
  56. /* to compute MFlop/s */
  57. uint64_t flop_cublas = 0;
  58. uint64_t flop_atlas = 0;
  59. /* to compute MB/s (load/store) */
  60. uint64_t ls_cublas = 0;
  61. uint64_t ls_atlas = 0;
  62. struct timeval start;
  63. struct timeval end;
  64. static int taskcounter __attribute__ ((unused));
  65. static struct block_conf conf __attribute__ ((aligned (128)));
  66. #define BLOCKSIZEX (xdim / nslicesx)
  67. #define BLOCKSIZEY (ydim / nslicesy)
  68. #define BLOCKSIZEZ (zdim / nslicesz)
  69. static void parse_args(int argc, char **argv)
  70. {
  71. int i;
  72. for (i = 1; i < argc; i++) {
  73. if (strcmp(argv[i], "-nblocks") == 0) {
  74. char *argptr;
  75. nslicesx = strtol(argv[++i], &argptr, 10);
  76. nslicesy = nslicesx;
  77. nslicesz = nslicesx;
  78. }
  79. if (strcmp(argv[i], "-nblocksx") == 0) {
  80. char *argptr;
  81. nslicesx = strtol(argv[++i], &argptr, 10);
  82. }
  83. if (strcmp(argv[i], "-nblocksy") == 0) {
  84. char *argptr;
  85. nslicesy = strtol(argv[++i], &argptr, 10);
  86. }
  87. if (strcmp(argv[i], "-nblocksz") == 0) {
  88. char *argptr;
  89. nslicesz = strtol(argv[++i], &argptr, 10);
  90. }
  91. if (strcmp(argv[i], "-x") == 0) {
  92. char *argptr;
  93. xdim = strtol(argv[++i], &argptr, 10);
  94. }
  95. if (strcmp(argv[i], "-y") == 0) {
  96. char *argptr;
  97. ydim = strtol(argv[++i], &argptr, 10);
  98. }
  99. if (strcmp(argv[i], "-z") == 0) {
  100. char *argptr;
  101. zdim = strtol(argv[++i], &argptr, 10);
  102. }
  103. if (strcmp(argv[i], "-iter") == 0) {
  104. char *argptr;
  105. niter = strtol(argv[++i], &argptr, 10);
  106. }
  107. if (strcmp(argv[i], "-no-random") == 0) {
  108. norandom = 1;
  109. }
  110. if (strcmp(argv[i], "-pin") == 0) {
  111. pin = 1;
  112. }
  113. if (strcmp(argv[i], "-common-model") == 0) {
  114. use_common_model = 1;
  115. }
  116. }
  117. assert(nslicesx <= MAXSLICESX);
  118. assert(nslicesy <= MAXSLICESY);
  119. assert(nslicesz <= MAXSLICESZ);
  120. }
  121. static void display_memory_consumption(void)
  122. {
  123. fprintf(stderr, "Total memory : %ld MB\n",
  124. (MAXSLICESY*MAXSLICESZ*sizeof(float *)
  125. + MAXSLICESZ*MAXSLICESX*sizeof(float *)
  126. + MAXSLICESY*MAXSLICESX*sizeof(float *)
  127. + MAXSLICESY*MAXSLICESZ*sizeof(starpu_data_handle)
  128. + MAXSLICESZ*MAXSLICESX*sizeof(starpu_data_handle)
  129. + MAXSLICESY*MAXSLICESX*sizeof(starpu_data_handle)
  130. + ydim*zdim*sizeof(float)
  131. + zdim*xdim*sizeof(float)
  132. + ydim*xdim*sizeof(float))/(1024*1024) );
  133. }
  134. #endif // __MULT_H__