32void sim_monitor(
char* filename,
volatile int* n,
volatile int* finished);
83 real* diag_offload_array) {
88 n_queue_size = n_particles;
102 print_err(
"Only GO mode ported to GPU. Please set SIM_MODE=1.");
106 print_err(
"RECORD_MODE=1 not ported to GPU. Please disable it.");
110 print_err(
"Atomic not yet ported to GPU. Please set ENABLE_ATOMIC=0.");
114 print_err(
"MHD not yet ported to GPU. Please set ENABLE_MHD=0.");
119 "ENABLE_ORBITWRITE=1 not ported to GPU. Please disable it.");
124 "ENABLE_TRANSCOEF=1 not ported to GPU. Please disable it.");
128 real* ptr;
int* ptrint;
131 NULL, 0, &ptr, &ptrint);
136 NULL, 0, &ptr, &ptrint);
141 NULL, 0, &ptr, &ptrint);
146 NULL, 0, &ptr, &ptrint);
158 NULL, 0, &ptr, &ptrint);
163 NULL, 0, &ptr, &ptrint);
168 NULL, 0, &ptr, &ptrint);
192 for(
int i = 0; i < n_particles; i++) {
200 for(
int i = 0; i < n_particles; i++) {
201 pq.
p[pq.
next++] = &p[i];
207 omp_get_max_threads());
215 omp_set_max_active_levels(2);
217#if !defined(GPU) && VERBOSE > 1
218 #pragma omp parallel sections num_threads(2)
231 OMP_PARALLEL_CPU_ONLY
235 OMP_PARALLEL_CPU_ONLY
240 OMP_PARALLEL_CPU_ONLY
244 OMP_PARALLEL_CPU_ONLY
248#if !defined(GPU) && VERBOSE > 1
254 char filename[519], outfn[256];
255 strcpy(outfn, sim_offload->
hdf5_out);
256 outfn[strlen(outfn)-3] =
'\0';
257 sprintf(filename,
"%s_%s.stdout", outfn, sim_offload->
qid);
277 for(
int i = 0; i < pq.
n; i++) {
298 for(
int i = 0; i < pq.
n; i++) {
306#if !defined(GPU) && VERBOSE > 1
307 #pragma omp parallel sections num_threads(2)
312 OMP_PARALLEL_CPU_ONLY
315#if !defined(GPU) && VERBOSE > 1
320 char filename[519], outfn[256];
321 strcpy(outfn, sim_offload->
hdf5_out);
322 outfn[strlen(outfn)-3] =
'\0';
323 sprintf(filename,
"%s_%s.stdout", outfn, sim_offload->
qid);
422void sim_monitor(
char* filename,
volatile int* n,
volatile int* finished) {
424 FILE *f = fopen(filename,
"w");
427 "Warning. %s could not be opened for progress updates.\n",
434 int n_temp, finished_temp;
438 finished_temp = *finished;
439 real fracprog = ((
real) finished_temp)/n_temp;
442 if(n_temp == finished_temp) {
447 fprintf(f,
"No marker has finished simulation yet. "
448 "Time spent: %.2f h\n", timespent/3600);
451 fprintf(f,
"Progress: %d/%d, %.2f %%. Time spent: %.2f h, "
452 "estimated time to finish: %.2f h\n", finished_temp, n_temp,
453 100*fracprog, timespent/3600, (1/fracprog-1)*timespent/3600);
459 fprintf(f,
"Simulation finished.\n");
int B_field_init(B_field_data *Bdata, B_field_offload_data *offload_data, real *offload_array)
Initialize magnetic field data struct on target.
int E_field_init(E_field_data *Edata, E_field_offload_data *offload_data, real *offload_array)
Initialize electric field data struct on target.
#define NSIMD
Number of particles simulated simultaneously in a particle group operations.
#define A5_WTIME
Wall time.
void asigma_extrapolate(int extrapolate)
Toggle extrapolation when evaluating cross sections.
int asigma_init(asigma_data *asigma_data, asigma_offload_data *offload_data, real *offload_array)
Initializes atomic reaction data struct on target.
Header file for asigma.c.
void boozer_init(boozer_data *boozerdata, boozer_offload_data *offload_data, real *offload_array)
Initialize boozer data struct on target.
void simulate_copy_to_gpu(sim_data *sim)
Copy data from CPU to GPU.
Header file for copytogpu.c.
void diag_init(diag_data *data, diag_offload_data *offload_data, real *offload_array)
Initializes diagnostics from offload data.
void diag_free(diag_data *data)
Free diagnostics data.
Header file for endcond.c.
void mccc_init(mccc_data *mdata, int include_energy, int include_pitch, int include_gcdiff)
Set collision operator data.
Header file for mccc package.
int mhd_init(mhd_data *mhddata, mhd_offload_data *offload_data, real *offload_array)
Initialize MHD data struct on target.
int neutral_init(neutral_data *ndata, neutral_offload_data *offload_data, real *offload_array)
Initialize neutral data struct on target.
void offload_unpack(offload_package *o, real *offload_array, size_t pack_length, int *int_offload_array, size_t int_pack_length, real **ptr, int **intptr)
Unpack offload array from the package.
Header file for offload.h.
Header file for particle.c.
int plasma_init(plasma_data *pls_data, plasma_offload_data *offload_data, real *offload_array)
Initialize plasma data struct on target.
Header file for plasma.c.
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
#define print_err(...)
Print to standard error.
Header file for random.c.
#define random_init(data, seed)
void simulate_init_offload(sim_offload_data *sim)
Initializes simulation settings.
void simulate(int id, int n_particles, particle_state *p, sim_offload_data *sim_offload, offload_package *offload_data, real *offload_array, int *int_offload_array, real *diag_offload_array)
Execute marker simulation.
void sim_init(sim_data *sim, sim_offload_data *offload_data)
Initialize simulation data struct on target.
void sim_monitor(char *filename, volatile int *n, volatile int *finished)
Monitor simulation progress.
Header file for simulate.c.
void simulate_fo_fixed(particle_queue *pq, sim_data *sim, int mrk_array_size)
Simulates particles using fixed time-step.
Header file for simulate_fo_fixed.c.
void simulate_gc_adaptive(particle_queue *pq, sim_data *sim)
Simulates guiding centers using adaptive time-step.
Header file for simulate_gc_adaptive.c.
void simulate_gc_fixed(particle_queue *pq, sim_data *sim)
Simulates guiding centers using fixed time-step.
Header file for simulate_gc_fixed.c.
void simulate_ml_adaptive(particle_queue *pq, sim_data *sim)
Simulates magnetic field-lines using adaptive time-step.
Header file for simulate_ml_adaptive.c.
Struct to keep track of the offload array length and unpack status.
General representation of a marker.
neutral_data neutral_data
Simulation offload struct.
B_field_offload_data B_offload_data
plasma_offload_data plasma_offload_data
neutral_offload_data neutral_offload_data
mhd_offload_data mhd_offload_data
asigma_offload_data asigma_offload_data
boozer_offload_data boozer_offload_data
wall_offload_data wall_offload_data
E_field_offload_data E_offload_data
diag_offload_data diag_offload_data
int int_offload_array_length
int wall_hit_wall(real r1, real phi1, real z1, real r2, real phi2, real z2, wall_data *w, real *w_coll)
Check if a given directed line segment intersects the wall.
int wall_init(wall_data *w, wall_offload_data *offload_data, real *offload_array, int *int_offload_array)
Initialize wall data struct on target.