cpu_nbody_between.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2019 Mael Keryell
  4. *
  5. * StarPU 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. * StarPU 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. #include <stdio.h>
  17. #include <stdint.h>
  18. #include <starpu.h>
  19. static inline long long jlstarpu_max(long long a, long long b)
  20. {
  21. return (a > b) ? a : b;
  22. }
  23. static inline long long jlstarpu_interval_size(long long start, long long step, long long stop)
  24. {
  25. if (stop >= start){
  26. return jlstarpu_max(0, (stop - start + 1) / step);
  27. } else {
  28. return jlstarpu_max(0, (stop - start - 1) / step);
  29. }
  30. }
  31. void nbody_acc(void** buffers_NJVQ1U4V, void* cl_arg_NJVQ1U4V)
  32. {
  33. uint32_t ld_xIZ5HaKV = (uint32_t) (STARPU_MATRIX_GET_LD(buffers_NJVQ1U4V[(1) - (1)]));
  34. double* ptr_xIZ5HaKV = (double*) (STARPU_MATRIX_GET_PTR(buffers_NJVQ1U4V[(1) - (1)]));
  35. uint32_t ld_QZvmSRYk = (uint32_t) (STARPU_MATRIX_GET_LD(buffers_NJVQ1U4V[(2) - (1)]));
  36. double* ptr_QZvmSRYk = (double*) (STARPU_MATRIX_GET_PTR(buffers_NJVQ1U4V[(2) - (1)]));
  37. double* ptr_U7pwlAjr = (double*) (STARPU_VECTOR_GET_PTR(buffers_NJVQ1U4V[(3) - (1)]));
  38. double* ptr_AQKcQq1a = (double*) (STARPU_VECTOR_GET_PTR(buffers_NJVQ1U4V[(4) - (1)]));
  39. int64_t* ptr_qQoIJuDP = (int64_t*) (STARPU_VECTOR_GET_PTR(buffers_NJVQ1U4V[(5) - (1)]));
  40. int64_t widthp = (int64_t) (STARPU_MATRIX_GET_NY(buffers_NJVQ1U4V[(1) - (1)]));
  41. int64_t widtha = (int64_t) (STARPU_MATRIX_GET_NY(buffers_NJVQ1U4V[(2) - (1)]));
  42. int64_t start_nj3HDzsW = (int64_t) (1);
  43. int64_t stop_nj3HDzsW = (int64_t) (widtha);
  44. int64_t plan;
  45. for (plan = start_nj3HDzsW ; plan <= stop_nj3HDzsW ; plan += 1)
  46. {
  47. double sumaccx = (double) (0);
  48. double sumaccy = (double) (0);
  49. int64_t start_TzfU6QY7 = (int64_t) (1);
  50. int64_t stop_TzfU6QY7 = (int64_t) (widthp);
  51. int64_t oplan;
  52. for (oplan = start_TzfU6QY7 ; oplan <= stop_TzfU6QY7 ; oplan += 1)
  53. {
  54. double eps = (double) (ptr_AQKcQq1a[(3) - (1)]);
  55. int64_t Id = (int64_t) ((ptr_qQoIJuDP[(1) - (1)]) * (widtha));
  56. double G = (double) (ptr_AQKcQq1a[(1) - (1)]);
  57. int64_t b = (int64_t) ((((plan) + (Id)) >= (oplan)) + (((plan) + (Id)) <= (oplan)));
  58. if ((b) < (2))
  59. {
  60. double dx = (double) ((ptr_xIZ5HaKV[((1) + (((oplan) - (1)) * (ld_xIZ5HaKV))) - (1)]) - (ptr_xIZ5HaKV[((1) + ((((plan) + (Id)) - (1)) * (ld_xIZ5HaKV))) - (1)]));
  61. double dy = (double) ((ptr_xIZ5HaKV[((2) + (((oplan) - (1)) * (ld_xIZ5HaKV))) - (1)]) - (ptr_xIZ5HaKV[((2) + ((((plan) + (Id)) - (1)) * (ld_xIZ5HaKV))) - (1)]));
  62. double modul = (double) (sqrt(((dx) * (dx)) + ((dy) * (dy))));
  63. sumaccx = (sumaccx) + (((G) * (ptr_U7pwlAjr[(oplan) - (1)]) * (dx)) / (((modul) + (eps)) * ((modul) + (eps)) * ((modul) + (eps))));
  64. sumaccy = (sumaccy) + (((G) * (ptr_U7pwlAjr[(oplan) - (1)]) * (dy)) / (((modul) + (eps)) * ((modul) + (eps)) * ((modul) + (eps))));
  65. };
  66. }
  67. ;
  68. ptr_QZvmSRYk[((1) + (((plan) - (1)) * (ld_QZvmSRYk))) - (1)] = sumaccx;
  69. ptr_QZvmSRYk[((2) + (((plan) - (1)) * (ld_QZvmSRYk))) - (1)] = sumaccy;
  70. /* ptr_QZvmSRYk[((1) + (((plan) - (1)) * (ld_QZvmSRYk))) - (1)] = ptr_qQoIJuDP[(1) - (1)]; */
  71. /* ptr_QZvmSRYk[((2) + (((plan) - (1)) * (ld_QZvmSRYk))) - (1)] = ptr_qQoIJuDP[(1) - (1)]; */
  72. }
  73. ;
  74. }
  75. void nbody_updt(void** buffers_kCJlJluA, void* cl_arg_kCJlJluA)
  76. {
  77. uint32_t ld_tlJ0FAub = (uint32_t) (STARPU_MATRIX_GET_LD(buffers_kCJlJluA[(1) - (1)]));
  78. double* ptr_tlJ0FAub = (double*) (STARPU_MATRIX_GET_PTR(buffers_kCJlJluA[(1) - (1)]));
  79. uint32_t ld_CwAKodfw = (uint32_t) (STARPU_MATRIX_GET_LD(buffers_kCJlJluA[(2) - (1)]));
  80. double* ptr_CwAKodfw = (double*) (STARPU_MATRIX_GET_PTR(buffers_kCJlJluA[(2) - (1)]));
  81. uint32_t ld_9CU1xW4b = (uint32_t) (STARPU_MATRIX_GET_LD(buffers_kCJlJluA[(3) - (1)]));
  82. double* ptr_9CU1xW4b = (double*) (STARPU_MATRIX_GET_PTR(buffers_kCJlJluA[(3) - (1)]));
  83. double* ptr_D81NeTCr = (double*) (STARPU_VECTOR_GET_PTR(buffers_kCJlJluA[(4) - (1)]));
  84. int64_t widthp = (int64_t) (STARPU_MATRIX_GET_NY(buffers_kCJlJluA[(1) - (1)]));
  85. int64_t start_FQShiJ9y = (int64_t) (1);
  86. int64_t stop_FQShiJ9y = (int64_t) (widthp);
  87. int64_t i;
  88. for (i = start_FQShiJ9y ; i <= stop_FQShiJ9y ; i += 1)
  89. {
  90. ptr_CwAKodfw[((1) + (((i) - (1)) * (ld_CwAKodfw))) - (1)] = (ptr_CwAKodfw[((1) + (((i) - (1)) * (ld_CwAKodfw))) - (1)]) + ((ptr_9CU1xW4b[((1) + (((i) - (1)) * (ld_9CU1xW4b))) - (1)]) * (ptr_D81NeTCr[(2) - (1)]));
  91. ptr_CwAKodfw[((2) + (((i) - (1)) * (ld_CwAKodfw))) - (1)] = (ptr_CwAKodfw[((2) + (((i) - (1)) * (ld_CwAKodfw))) - (1)]) + ((ptr_9CU1xW4b[((2) + (((i) - (1)) * (ld_9CU1xW4b))) - (1)]) * (ptr_D81NeTCr[(2) - (1)]));
  92. ptr_tlJ0FAub[((1) + (((i) - (1)) * (ld_tlJ0FAub))) - (1)] = (ptr_tlJ0FAub[((1) + (((i) - (1)) * (ld_tlJ0FAub))) - (1)]) + ((ptr_CwAKodfw[((1) + (((i) - (1)) * (ld_CwAKodfw))) - (1)]) * (ptr_D81NeTCr[(2) - (1)]));
  93. ptr_tlJ0FAub[((2) + (((i) - (1)) * (ld_tlJ0FAub))) - (1)] = (ptr_tlJ0FAub[((2) + (((i) - (1)) * (ld_tlJ0FAub))) - (1)]) + ((ptr_CwAKodfw[((2) + (((i) - (1)) * (ld_CwAKodfw))) - (1)]) * (ptr_D81NeTCr[(2) - (1)]));
  94. }
  95. ;
  96. }