main.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // #ifdef __cplusplus
  2. // extern "C" {
  3. // #endif
  4. //===============================================================================================================================================================================================================200
  5. // DEFINE / INCLUDE
  6. //===============================================================================================================================================================================================================200
  7. #define fp float
  8. #define NUMBER_PAR_PER_BOX 100 // keep this low to allow more blocks that share shared memory to run concurrently, code does not work for larger than 110, more speedup can be achieved with larger number and no shared memory used
  9. //#define NUMBER_THREADS 128 // this should be roughly equal to NUMBER_PAR_PER_BOX for best performance
  10. // Parameterized work group size
  11. #ifdef RD_WG_SIZE_0_0
  12. #define NUMBER_THREADS RD_WG_SIZE_0_0
  13. #elif defined(RD_WG_SIZE_0)
  14. #define NUMBER_THREADS RD_WG_SIZE_0
  15. #elif defined(RD_WG_SIZE)
  16. #define NUMBER_THREADS RD_WG_SIZE
  17. #else
  18. #define NUMBER_THREADS 64
  19. #endif
  20. #define DOT(A,B) ((A.x)*(B.x)+(A.y)*(B.y)+(A.z)*(B.z)) // STABLE
  21. //===============================================================================================================================================================================================================200
  22. // STRUCTURES
  23. //===============================================================================================================================================================================================================200
  24. typedef struct
  25. {
  26. fp x, y, z;
  27. } THREE_VECTOR;
  28. typedef struct
  29. {
  30. fp v, x, y, z;
  31. } FOUR_VECTOR;
  32. typedef struct nei_str
  33. {
  34. // neighbor box
  35. int x, y, z;
  36. int number;
  37. long long offset;
  38. } nei_str;
  39. typedef struct box_str
  40. {
  41. // home box
  42. int x, y, z;
  43. int number;
  44. long long offset;
  45. // neighbor boxes
  46. int nn;
  47. nei_str nei[26];
  48. } box_str;
  49. typedef struct par_str
  50. {
  51. fp alpha;
  52. } par_str;
  53. typedef struct dim_str
  54. {
  55. // input arguments
  56. int cur_arg;
  57. int arch_arg;
  58. int cores_arg;
  59. int boxes1d_arg;
  60. // system memory
  61. long long number_boxes;
  62. long long box_mem;
  63. long long space_elem;
  64. long long space_mem;
  65. long long space_mem2;
  66. } dim_str;
  67. //===============================================================================================================================================================================================================200
  68. // FUNCTION PROTOTYPES
  69. //===============================================================================================================================================================================================================200
  70. int
  71. main( int argc,
  72. char *argv []);
  73. //===============================================================================================================================================================================================================200
  74. // END
  75. //===============================================================================================================================================================================================================200
  76. // #ifdef __cplusplus
  77. // }
  78. // #endif