diff --git a/lib/sapporo_light/sapporo.cpp b/lib/sapporo_light/sapporo.cpp index 3ad6e5ab83..1afd0c1c4e 100644 --- a/lib/sapporo_light/sapporo.cpp +++ b/lib/sapporo_light/sapporo.cpp @@ -270,3 +270,8 @@ int sapporo::get_ngb_list(int cluster_id, sort(nbl, nbl + min(nblen, maxlength)); return overflow; } + +int sapporo::get_nj_max() const +{ + return nj_max; +} diff --git a/lib/sapporo_light/sapporo.h b/lib/sapporo_light/sapporo.h index cb8b60ce59..1a2469e8ef 100644 --- a/lib/sapporo_light/sapporo.h +++ b/lib/sapporo_light/sapporo.h @@ -103,6 +103,9 @@ extern "C" { int get_device_count(); cudaError_t host_evaluate_gravity(sapporo_multi_struct); +#ifdef __cplusplus + int g6_get_nj_max_(); +#endif } class sapporo { @@ -169,7 +172,7 @@ class sapporo { predict = false; nj_modified = 0; - + device.address_j = NULL; device.t_j = NULL; @@ -182,6 +185,7 @@ class sapporo { device.acc_i = NULL; device.vel_i = NULL; device.jrk_i = NULL; + }; ~sapporo() {}; @@ -189,6 +193,7 @@ class sapporo { int open(int cluster_id); int close(int cluster_id); int get_n_pipes(); + int get_nj_max() const; int set_ti(int cluster_id, double ti); int set_j_particle(int cluster_id, diff --git a/lib/sapporo_light/sapporoG6lib.cpp b/lib/sapporo_light/sapporoG6lib.cpp index 3aff64394f..c4c4481949 100644 --- a/lib/sapporo_light/sapporoG6lib.cpp +++ b/lib/sapporo_light/sapporoG6lib.cpp @@ -49,6 +49,9 @@ extern "C" { return grav.calc_lasthalf2(*cluster_id, *nj, *ni, index, xi, vi, *eps2, h2, acc, jerk, pot, inn); } + int g6_get_nj_max_() { + return grav.get_nj_max(); + } int g6_initialize_jp_buffer_(int* cluster_id, int* buf_size) {return 0;} int g6_flush_jp_buffer_(int* cluster_id) {return 0;} @@ -80,4 +83,3 @@ extern "C" { } - diff --git a/src/amuse_ph4/interface.cc b/src/amuse_ph4/interface.cc index 970b9f4409..7357091895 100644 --- a/src/amuse_ph4/interface.cc +++ b/src/amuse_ph4/interface.cc @@ -936,3 +936,9 @@ int get_id_of_updated_particle(int index, int * index_of_particle, int * status) *status = jd->UpdatedParticles[index].status; return 0; } + +int get_nj_max(int * value) +{ + *value = jd->get_nj_max(); + return 0; +} diff --git a/src/amuse_ph4/interface.py b/src/amuse_ph4/interface.py index 0c9f26062c..dca15222bf 100644 --- a/src/amuse_ph4/interface.py +++ b/src/amuse_ph4/interface.py @@ -464,6 +464,13 @@ def recompute_timesteps(): function.result_type = 'int32' return function + @legacy_function + def get_nj_max(): + function = LegacyFunctionSpecification() + function.addParameter('nj_max', dtype='int32', + direction=function.OUT) + function.result_type = 'int32' + return function class ph4(GravitationalDynamics,GravityFieldCode): diff --git a/src/amuse_ph4/src/jdata.cc b/src/amuse_ph4/src/jdata.cc index f5530ee36a..9acef22d21 100644 --- a/src/amuse_ph4/src/jdata.cc +++ b/src/amuse_ph4/src/jdata.cc @@ -34,6 +34,7 @@ #ifdef GPU #include "grape.h" +#include "sapporo.h" #endif // AMUSE STOPPING CONDITIONS SUPPORT @@ -1153,3 +1154,12 @@ real jdata::get_tnext() int ndum; return sched->get_list(NULL, ndum); } + +int jdata::get_nj_max() +{ +#ifdef GPU + return g6_get_nj_max_(); +#else + return std::numeric_limits::max(); +#endif +} diff --git a/src/amuse_ph4/src/jdata.h b/src/amuse_ph4/src/jdata.h index 9ec464dfb7..069bd57095 100644 --- a/src/amuse_ph4/src/jdata.h +++ b/src/amuse_ph4/src/jdata.h @@ -212,6 +212,7 @@ class jdata { void spec_output(const char *s = NULL); void to_com(); real get_tnext(); + int get_nj_max(); // In gpu.cc: