Skip to content

Commit

Permalink
Merge pull request #46 from streeve/warnings
Browse files Browse the repository at this point in the history
Fix warnings
  • Loading branch information
streeve authored Feb 24, 2023
2 parents 0dade55 + 9d669bd commit 3d22919
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 97 deletions.
2 changes: 1 addition & 1 deletion decks/custom_init.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Custom_Particle_Initializer : public Particle_Initializer {
particle_list_t& particles,
size_t nx,
size_t ny,
size_t nz,
size_t,
size_t ng,
real_ dxp,
size_t nppc,
Expand Down
14 changes: 14 additions & 0 deletions example/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@

#include "input/deck.h"

// Requires C++14
static auto make_field_solver(field_array_t &fields)
{
// TODO: make this support 1/2/3d
#ifdef ES_FIELD_SOLVER
std::cout << "Created ES Solver" << std::endl;
Field_Solver<ES_Field_Solver> field_solver(fields);
#else // EM
std::cout << "Created EM Solver" << std::endl;
Field_Solver<EM_Field_Solver> field_solver(fields);
#endif
return field_solver;
}

// Global variable to hold paramters
//Parameters params;
Input_Deck deck;
Expand Down
11 changes: 5 additions & 6 deletions src/accumulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
void clear_accumulator_array(
field_array_t& fields,
accumulator_array_t& accumulators,
size_t nx, // TODO: we can probably pull these out of global params..
size_t ny,
size_t nz
size_t, // TODO: we can probably pull these out of global params..
size_t,
size_t
)
{
auto _clean_accumulator = KOKKOS_LAMBDA(const int i)
Expand Down Expand Up @@ -39,7 +39,7 @@ void clear_accumulator_array(
};

Kokkos::RangePolicy<ExecutionSpace> exec_policy( 0, fields.size() );
Kokkos::parallel_for( exec_policy, _clean_accumulator, "clean_accumulator()" );
Kokkos::parallel_for( "clean_accumulator()", exec_policy, _clean_accumulator );
}

void unload_accumulator_array(
Expand Down Expand Up @@ -107,7 +107,7 @@ void unload_accumulator_array(

//may not be enough if particles run into ghost cells
Kokkos::MDRangePolicy< Kokkos::Rank<3> > non_ghost_policy( {ng,ng,ng}, {nx+ng+1, ny+ng+1, nz+ng+1} ); // Try not to into ghosts // TODO: dry this
Kokkos::parallel_for( non_ghost_policy, _unload_accumulator, "unload_accumulator()" );
Kokkos::parallel_for( "unload_accumulator()", non_ghost_policy, _unload_accumulator );

/* // Crib sheet for old variable names
a0 = &a(x, y, z );
Expand All @@ -120,4 +120,3 @@ void unload_accumulator_array(
*/

}

118 changes: 52 additions & 66 deletions src/fields.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void serial_update_ghosts_B(
//}

Kokkos::MDRangePolicy<Kokkos::Rank<2>> zy_policy({1,1}, {nz+1,ny+1});
Kokkos::parallel_for( zy_policy, _zy_boundary, "zy boundary()" );
Kokkos::parallel_for( "zy boundary()", zy_policy, _zy_boundary );

//for (int x = 0; x < nx+2; x++) {
//for (int z = 1; z < nz+1; z++) {
Expand All @@ -73,7 +73,7 @@ void serial_update_ghosts_B(
};
//}
Kokkos::MDRangePolicy<Kokkos::Rank<2>> xz_policy({0,1}, {nx+2,nz+1});
Kokkos::parallel_for( xz_policy, _xz_boundary, "xz boundary()" );
Kokkos::parallel_for( "xz boundary()", xz_policy, _xz_boundary );

//for (int y = 0; y < ny+2; y++) {
//for (int x = 0; x < nx+2; x++) {
Expand All @@ -95,7 +95,7 @@ void serial_update_ghosts_B(
};
//}
Kokkos::MDRangePolicy<Kokkos::Rank<2>> yx_policy({0,0}, {ny+2,nx+2});
Kokkos::parallel_for( yx_policy, _yx_boundary, "yx boundary()" );
Kokkos::parallel_for( "yx boundary()", yx_policy, _yx_boundary );
}
}

Expand Down Expand Up @@ -140,7 +140,7 @@ void serial_update_ghosts(
}
};
Kokkos::RangePolicy<ExecutionSpace> x_policy(1, nx+1);
Kokkos::parallel_for( x_policy, _x_boundary, "_x_boundary()" );
Kokkos::parallel_for( "_x_boundary()", x_policy, _x_boundary );

//for ( y = 1; y <= ny; y++ ){
auto _y_boundary = KOKKOS_LAMBDA( const int y )
Expand All @@ -160,7 +160,7 @@ void serial_update_ghosts(
}
};
Kokkos::RangePolicy<ExecutionSpace> y_policy(1, ny+1);
Kokkos::parallel_for( y_policy, _y_boundary, "_y_boundary()" );
Kokkos::parallel_for( "_y_boundary()", y_policy, _y_boundary );

//for ( z = 1; z <= nz; z++ ){
auto _z_boundary = KOKKOS_LAMBDA( const int z )
Expand All @@ -180,7 +180,7 @@ void serial_update_ghosts(
}
};
Kokkos::RangePolicy<ExecutionSpace> z_policy(1, nz+1);
Kokkos::parallel_for( z_policy, _z_boundary, "_z_boundary()" );
Kokkos::parallel_for( "_z_boundary()", z_policy, _z_boundary );

// // Copy x from RHS -> LHS
// int x = 1;
Expand Down Expand Up @@ -311,7 +311,7 @@ template<typename Solver_Type> class Field_Solver : public Solver_Type
jfz(i) = 0.0;
};

Kokkos::parallel_for( fields.size(), _init_fields, "init_fields()" );
Kokkos::parallel_for( "init_fields()", fields.size(), _init_fields );
}

void advance_b(
Expand Down Expand Up @@ -349,28 +349,28 @@ class ES_Field_Solver
public:

void advance_b(
field_array_t& fields,
real_t px,
real_t py,
real_t pz,
size_t nx,
size_t ny,
size_t nz,
size_t ng
field_array_t&,
real_t,
real_t,
real_t,
size_t,
size_t,
size_t,
size_t
)
{
// No-op, becasue ES
}

void advance_e(
field_array_t& fields,
real_t px,
real_t py,
real_t pz,
size_t nx,
size_t ny,
size_t nz,
size_t ng,
real_t,
real_t,
real_t,
size_t,
size_t,
size_t,
size_t,
real_t dt_eps0
)
{
Expand All @@ -397,17 +397,17 @@ class ES_Field_Solver
};

Kokkos::RangePolicy<ExecutionSpace> exec_policy( 0, fields.size() );
Kokkos::parallel_for( exec_policy, _advance_e, "es_advance_e()" );
Kokkos::parallel_for( "es_advance_e()", exec_policy, _advance_e );
}

real_t e_energy(
field_array_t& fields,
real_t px,
real_t py,
real_t pz,
size_t nx,
size_t ny,
size_t nz
real_t,
real_t,
real_t,
size_t,
size_t,
size_t
)
{
auto ex = Cabana::slice<FIELD_EX>(fields);
Expand All @@ -434,12 +434,12 @@ class ES_Field_Solver_1D

real_t e_energy(
field_array_t& fields,
real_t px,
real_t py,
real_t pz,
size_t nx,
size_t ny,
size_t nz
real_t,
real_t,
real_t,
size_t,
size_t,
size_t
)
{
auto ex = Cabana::slice<FIELD_EX>(fields);
Expand All @@ -460,9 +460,9 @@ class ES_Field_Solver_1D

void advance_e(
field_array_t& fields,
real_t px,
real_t py,
real_t pz,
real_t,
real_t,
real_t,
size_t nx,
size_t ny,
size_t nz,
Expand Down Expand Up @@ -490,7 +490,7 @@ class ES_Field_Solver_1D
};

Kokkos::RangePolicy<ExecutionSpace> exec_policy( 0, fields.size() );
Kokkos::parallel_for( exec_policy, _advance_e, "es_advance_e_1d()" );
Kokkos::parallel_for( "es_advance_e_1d()", exec_policy, _advance_e );
}
};

Expand All @@ -507,14 +507,14 @@ class EM_Field_Solver
void dump_fields(FILE * fp,
field_array_t& d_fields,
real_t xmin,
real_t ymin,
real_t zmin,
real_t,
real_t,
real_t dx,
real_t dy,
real_t dz,
real_t,
real_t,
size_t nx,
size_t ny,
size_t nz,
size_t,
size_t ng
)
{
Expand All @@ -540,9 +540,9 @@ class EM_Field_Solver

real_t e_energy(
field_array_t& fields,
real_t px,
real_t py,
real_t pz,
real_t,
real_t,
real_t,
size_t nx,
size_t ny,
size_t nz,
Expand Down Expand Up @@ -572,9 +572,9 @@ class EM_Field_Solver

real_t b_energy(
field_array_t& fields,
real_t px,
real_t py,
real_t pz,
real_t,
real_t,
real_t,
size_t nx,
size_t ny,
size_t nz,
Expand Down Expand Up @@ -646,7 +646,7 @@ class EM_Field_Solver
};

Kokkos::MDRangePolicy<Kokkos::Rank<3>> zyx_policy({1, 1, 1}, {nx+2, ny+2, nz+2});
Kokkos::parallel_for( zyx_policy, _advance_e, "advance_e()" );
Kokkos::parallel_for( "advance_e()", zyx_policy, _advance_e );
}


Expand Down Expand Up @@ -699,25 +699,11 @@ class EM_Field_Solver
};

Kokkos::MDRangePolicy<Kokkos::Rank<3>> zyx_policy({1, 1, 1}, {nx+1, ny+1, nz+1});
Kokkos::parallel_for( zyx_policy, _advance_b, "advance_b()" );
Kokkos::parallel_for( "advance_b()", zyx_policy, _advance_b );
serial_update_ghosts_B(cbx, cby, cbz, nx, ny, nz, ng);
}
};

// Requires C++14
static auto make_field_solver(field_array_t& fields)
{
// TODO: make this support 1/2/3d
#ifdef ES_FIELD_SOLVER
std::cout << "Created ES Solver" << std::endl;
Field_Solver<ES_Field_Solver> field_solver(fields);
#else // EM
std::cout << "Created EM Solver" << std::endl;
Field_Solver<EM_Field_Solver> field_solver(fields);
#endif
return field_solver;
}

template<typename field_solver_t>
void dump_energies(
field_solver_t& field_solver,
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int allow_for_ghosts(int pre_ghost)
}

// Function to print out the data for every particle.
void dump_particles( FILE * fp, const particle_list_t d_particles, const real_t xmin, const real_t ymin, const real_t zmin, const real_t dx, const real_t dy, const real_t dz,size_t nx,size_t ny,size_t nz, size_t ng)
void dump_particles( FILE * fp, const particle_list_t d_particles, const real_t xmin, const real_t, const real_t, const real_t dx, const real_t, const real_t, size_t nx,size_t ny,size_t, size_t ng)
{

// Host
Expand Down Expand Up @@ -110,7 +110,7 @@ void print_fields( const field_array_t& fields )
};

Kokkos::RangePolicy<ExecutionSpace> exec_policy( 0, fields.size() );
Kokkos::parallel_for( exec_policy, _print_fields, "print()" );
Kokkos::parallel_for( "print()", exec_policy, _print_fields );

std::cout << std::endl;

Expand Down
32 changes: 16 additions & 16 deletions src/input/deck.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ class Field_Initializer {

virtual void init(
field_array_t& fields,
size_t nx,
size_t ny,
size_t nz,
size_t ng,
real_ Lx, // TODO: do we prefer xmin or Lx?
real_ Ly,
real_ Lz,
real_ dx,
real_ dy,
real_ dz
size_t,
size_t,
size_t,
size_t,
real_, // TODO: do we prefer xmin or Lx?
real_,
real_,
real_,
real_,
real_
)
{
std::cout << "Default field init" << std::endl;
Expand All @@ -62,7 +62,7 @@ class Field_Initializer {
cbz(i) = 0.0;
};

Kokkos::parallel_for( fields.size(), _init_fields, "zero_fields()" );
Kokkos::parallel_for( "zero_fields()", fields.size(), _init_fields );

}
};
Expand All @@ -80,15 +80,15 @@ class Particle_Initializer {
particle_list_t& particles,
size_t nx,
size_t ny,
size_t nz,
size_t ng,
size_t,
size_t,
real_ dxp,
size_t nppc,
real_ w,
real_ v0,
real_ Lx,
real_ Ly,
real_ Lz
real_,
real_,
real_
)
{
// TODO: this doesnt currently do anything with nppc/num_cells
Expand Down
Loading

0 comments on commit 3d22919

Please sign in to comment.