Skip to content

Commit 30ec270

Browse files
authored
Merge pull request #18 from treecode/Address_comment_AMUSE_issue_1209
Add get_nj_max function similar to Sapporo Light
2 parents 7cae51e + 171bc3b commit 30ec270

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

src/interfaces/sapporoG6lib.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,11 @@ extern "C" {
147147
// return grav.calc_lasthalf2(*cluster_id, *nj, *ni,
148148
// index, xi, vi, *eps2, h2, acc, jerk, pot, inn);
149149
}
150-
151-
150+
151+
int g6_get_nj_max_() {
152+
return grav.get_nj_max();
153+
}
154+
152155
void get_j_part_data(int addr, int nj,
153156
double *pos,
154157
double *vel,

src/sapporohostclass.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ int sapporo::open(std::string kernelFile, int *devices,
159159

160160
//Allocate initial memory for 16k particles per device
161161
sapdevice->allocateMemory(16384, get_n_pipes());
162-
nj_max = 16384;
162+
nj_max = 262144; //Initial max number of j-particles, can be increased if needed
163163
}//end pragma omp parallel
164164

165165
//Used to store j-memory particle counters
@@ -461,7 +461,8 @@ int sapporo::set_j_particle(int address,
461461
//Extra check, if we are still outside nj_max, we quit since particles are not
462462
//nicely send in order
463463
if (address >= nj_max) {
464-
fprintf(stderr, "Increasing nj_max was not enough! Send particles in order to the library! Exit\n");
464+
fprintf(stderr, "Increasing nj_max = %d was not enough, address = %d\n", nj_max, address);
465+
fprintf(stderr, "Send particles in order to the library! Exit\n");
465466
exit(-1);
466467
}
467468
}
@@ -1601,3 +1602,8 @@ double sapporo::evaluate_gravity(int ni_total, int nj)
16011602
return 0.0;
16021603
} //end evaluate gravity
16031604

1605+
1606+
int sapporo::get_nj_max() const
1607+
{
1608+
return nj_max;
1609+
}

src/sapporohostclass.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ struct jCopyInfo
3232
int toCopy;
3333
} typedef jCopyInfo;
3434

35-
35+
extern "C"
36+
{
37+
int g6_get_nj_max_();
38+
}
3639

3740
class sapporo {
3841
protected:
@@ -126,6 +129,7 @@ class sapporo {
126129
int order = FOURTH, int precision = DOUBLESINGLE);
127130
int close();
128131
int get_n_pipes();
132+
int get_nj_max() const;
129133
int set_time(double ti);
130134
int set_no_time();
131135

0 commit comments

Comments
 (0)