Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/sapporo_light/sapporo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
14 changes: 13 additions & 1 deletion lib/sapporo_light/sapporo.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class sapporo {

predict = false;
nj_modified = 0;

device.address_j = NULL;

device.t_j = NULL;
Expand All @@ -182,8 +182,10 @@ class sapporo {
device.acc_i = NULL;
device.vel_i = NULL;
device.jrk_i = NULL;


};
int get_nj_max() const;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works fine, but maybe it belongs with get_n_pipes on line 191?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, you mean that would be a better place in terms of the program's logic?

~sapporo() {};

int open(int cluster_id);
Expand Down Expand Up @@ -230,3 +232,13 @@ class sapporo {
};

#endif

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be above the #endif on 232, or things will go wrong when there's a header include loop. Maybe just add it on line 104 inside the existing extern "C" block there?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, will do.

#ifdef __cplusplus
extern "C" {
#endif

int g6_get_nj_max_();

#ifdef __cplusplus
}
#endif
4 changes: 3 additions & 1 deletion lib/sapporo_light/sapporoG6lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down Expand Up @@ -80,4 +83,3 @@ extern "C" {


}

6 changes: 6 additions & 0 deletions src/amuse_ph4/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 7 additions & 0 deletions src/amuse_ph4/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,13 @@ def recompute_timesteps():
function.result_type = 'int32'
return function

Comment thread
LourensVeen marked this conversation as resolved.
@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):

Expand Down
10 changes: 10 additions & 0 deletions src/amuse_ph4/src/jdata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#ifdef GPU
#include "grape.h"
#include "sapporo.h"
#endif

// AMUSE STOPPING CONDITIONS SUPPORT
Expand Down Expand Up @@ -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 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So on the CPU we support no particles at all? I think it makes sense to put a large number here, like INT_MAX from limits.h or, since it's C++, std::numeric_limits<int>::max() from limits. That way a script that checks won't always crash in CPU mode, only when it runs out of memory.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, that makes sense. I will add that.

#endif
}
1 change: 1 addition & 0 deletions src/amuse_ph4/src/jdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
Loading