Skip to content

Commit

Permalink
Merge pull request #81 from ExCALIBUR-NEPTUNE/stp/fix_clang_warnings
Browse files Browse the repository at this point in the history
Stp/fix clang warnings
  • Loading branch information
will-saunders-ukaea authored Nov 5, 2024
2 parents 35a6d53 + 0f2cd95 commit e215503
Show file tree
Hide file tree
Showing 53 changed files with 338 additions and 265 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ add_library(NESO-Particles INTERFACE)
# Alias the name to the namespaces name. Can use in subdirectory or via Confiig
# files with namespace
add_library(NESO-Particles::NESO-Particles ALIAS NESO-Particles)
target_compile_options(NESO-Particles INTERFACE "-Wpedantic;-Wall;-Wextra")

# Set standard
set_property(TARGET NESO-Particles PROPERTY CXX_STANDARD 17)
Expand Down
6 changes: 3 additions & 3 deletions include/neso_particles/boundary_conditions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CartesianPeriodic {
/// Disable (implicit) copies.
CartesianPeriodic &operator=(CartesianPeriodic const &a) = delete;

~CartesianPeriodic(){};
~CartesianPeriodic() {};

/**
* Construct instance to apply periodic boundary conditions to particles
Expand All @@ -44,7 +44,7 @@ class CartesianPeriodic {
CartesianPeriodic(SYCLTargetSharedPtr sycl_target,
std::shared_ptr<CartesianHMesh> mesh,
ParticleDatSharedPtr<REAL> position_dat)
: mesh(mesh), sycl_target(sycl_target), d_extents(sycl_target, 3),
: d_extents(sycl_target, 3), sycl_target(sycl_target), mesh(mesh),
position_dat(position_dat) {

NESOASSERT(mesh->ndim <= 3, "bad mesh ndim");
Expand Down Expand Up @@ -89,7 +89,7 @@ class CartesianPeriodic {
CartesianPeriodic(std::shared_ptr<CartesianHMesh> mesh,
ParticleGroupSharedPtr particle_group)
: CartesianPeriodic(particle_group->sycl_target, mesh,
particle_group->position_dat){
particle_group->position_dat) {

};

Expand Down
4 changes: 3 additions & 1 deletion include/neso_particles/cartesian_mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class CartesianHMeshLocalMapperT : public LocalMapper {
/// Disable (implicit) copies.
CartesianHMeshLocalMapperT &
operator=(CartesianHMeshLocalMapperT const &a) = delete;
virtual ~CartesianHMeshLocalMapperT() = default;

/// CartesianHMesh on which the lookup is based.
CartesianHMeshSharedPtr mesh;
Expand Down Expand Up @@ -307,7 +308,8 @@ class CartesianHMeshLocalMapperT : public LocalMapper {
*
* @param particle_group ParticleGroup.
*/
inline void particle_group_callback(ParticleGroup &particle_group) override{};
inline void particle_group_callback(
[[maybe_unused]] ParticleGroup &particle_group) override {};
};

inline std::shared_ptr<CartesianHMeshLocalMapperT>
Expand Down
10 changes: 5 additions & 5 deletions include/neso_particles/cell_binning.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CartesianCellBin {
/// Disable (implicit) copies.
CartesianCellBin &operator=(CartesianCellBin const &a) = delete;

~CartesianCellBin(){};
~CartesianCellBin() {};

/**
* Create instance to bin particles into cells of a CartesianHMesh.
Expand All @@ -82,9 +82,9 @@ class CartesianCellBin {
*/
CartesianCellBin(SYCLTargetSharedPtr sycl_target,
CartesianHMeshSharedPtr mesh)
: sycl_target(sycl_target), mesh(mesh), position_dat(nullptr),
cell_id_dat(nullptr), d_cell_counts(sycl_target, 3),
d_cell_starts(sycl_target, 3), d_cell_ends(sycl_target, 3) {
: d_cell_counts(sycl_target, 3), d_cell_starts(sycl_target, 3),
d_cell_ends(sycl_target, 3), sycl_target(sycl_target), mesh(mesh),
position_dat(nullptr), cell_id_dat(nullptr) {

NESOASSERT(mesh->ndim <= 3, "bad mesh ndim");
BufferHost<int> h_cell_counts(sycl_target, 3);
Expand Down Expand Up @@ -147,7 +147,7 @@ class CartesianCellBin {
* @param map_cell Cell to map.
*/
inline void map_cells(ParticleGroup &particle_group,
const int map_cell = -1) {
[[maybe_unused]] const int map_cell = -1) {
this->get_loop(particle_group.position_dat, particle_group.cell_id_dat)
->execute();
}
Expand Down
2 changes: 1 addition & 1 deletion include/neso_particles/cell_dat_compression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class LayerCompressor {
auto r =
ProfileRegion("LayerCompressor", "compute_remove_compress_indicies_a");

NESOASSERT(this->d_npart_cell.size >= this->ncell,
NESOASSERT(this->d_npart_cell.size >= static_cast<std::size_t>(this->ncell),
"Bad device_npart_cell length");

const int ncell = this->ncell;
Expand Down
7 changes: 3 additions & 4 deletions include/neso_particles/cell_dat_move.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ class CellMove {
LayerCompressor &layer_compressor,
std::map<Sym<REAL>, ParticleDatSharedPtr<REAL>> &particle_dats_real,
std::map<Sym<INT>, ParticleDatSharedPtr<INT>> &particle_dats_int)
: ncell(ncell), sycl_target(sycl_target),
layer_compressor(layer_compressor),
particle_dats_real(particle_dats_real),
: ncell(ncell), particle_dats_real(particle_dats_real),
particle_dats_int(particle_dats_int),
h_npart_cell(sycl_target, this->ncell),
d_npart_cell(sycl_target, this->ncell),
Expand All @@ -189,7 +187,8 @@ class CellMove {
d_particle_dat_ptr_int(sycl_target, 1),
d_particle_dat_ncomp_real(sycl_target, 1),
d_particle_dat_ncomp_int(sycl_target, 1),
ep_bad_cell_indices(sycl_target) {}
layer_compressor(layer_compressor), ep_bad_cell_indices(sycl_target),
sycl_target(sycl_target) {}

/**
* Set the ParticleDat to use as a source for cell ids.
Expand Down
19 changes: 10 additions & 9 deletions include/neso_particles/compute_target.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ class SYCLTarget {
}
}

inline void check_ptr(unsigned char *ptr_user, const size_t size_bytes) {
inline void check_ptr([[maybe_unused]] unsigned char *ptr_user,
[[maybe_unused]] const size_t size_bytes) {

#ifdef DEBUG_OOB_CHECK
this->queue
Expand Down Expand Up @@ -329,7 +330,7 @@ template <typename T> class BufferBase {
}

BufferBase(SYCLTargetSharedPtr sycl_target, std::size_t size)
: sycl_target(sycl_target), size(size), ptr(nullptr) {}
: sycl_target(sycl_target), ptr(nullptr), size(size) {}

inline void assert_allocated() {
NESOASSERT(this->ptr != nullptr,
Expand Down Expand Up @@ -490,7 +491,7 @@ template <typename T> class BufferDevice : public BufferBase<T> {
this->set(vec);
}

~BufferDevice() { this->generic_free(); }
virtual ~BufferDevice() { this->generic_free(); }
};

/**
Expand All @@ -503,7 +504,7 @@ template <typename T> class BufferShared : public BufferBase<T> {
sycl::malloc_shared(num_bytes, this->sycl_target->queue));
}
virtual inline void free_wrapper(T *ptr) override {
sycl::free(this->ptr, this->sycl_target->queue);
sycl::free(ptr, this->sycl_target->queue);
}

public:
Expand Down Expand Up @@ -606,7 +607,7 @@ template <typename T> class BufferDeviceHost {
/// Wrapped BufferHost.
BufferHost<T> h_buffer;

~BufferDeviceHost(){};
~BufferDeviceHost() {};

/**
* Create a new BufferDeviceHost of the request size on the requested compute
Expand All @@ -618,7 +619,7 @@ template <typename T> class BufferDeviceHost {
*/
BufferDeviceHost(SYCLTargetSharedPtr sycl_target, size_t size)
: sycl_target(sycl_target), size(size), d_buffer(sycl_target, size),
h_buffer(sycl_target, size){};
h_buffer(sycl_target, size) {};

/**
* Create a new BufferDeviceHost from a std::vector. Note, this does not
Expand All @@ -629,7 +630,7 @@ template <typename T> class BufferDeviceHost {
*/
BufferDeviceHost(SYCLTargetSharedPtr sycl_target, const std::vector<T> &vec)
: sycl_target(sycl_target), size(vec.size()), d_buffer(sycl_target, vec),
h_buffer(sycl_target, vec){};
h_buffer(sycl_target, vec) {};

/**
* Get the size in bytes of the allocation on the host and device.
Expand Down Expand Up @@ -718,12 +719,12 @@ class EventStack {
std::stack<sycl::event> stack;

public:
~EventStack(){};
~EventStack() {};

/**
* Create a new and empty stack of events.
*/
EventStack(){};
EventStack() {};

/**
* Push a sycl::event onto the event stack.
Expand Down
22 changes: 13 additions & 9 deletions include/neso_particles/containers/cell_dat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,24 @@ inline void create_kernel_arg(ParticleLoopIteration &iterationx, T ***&rhs,
lhs.cell = iterationx.cellx;
}
template <typename T>
inline T *const *const *create_loop_arg(ParticleLoopGlobalInfo *global_info,
sycl::handler &cgh,
Access::Read<CellDat<T> *> &a) {
inline T *const *const *
create_loop_arg([[maybe_unused]] ParticleLoopGlobalInfo *global_info,
[[maybe_unused]] sycl::handler &cgh,
Access::Read<CellDat<T> *> &a) {
return a.obj->impl_get_const();
}
template <typename T>
inline T ***create_loop_arg(ParticleLoopGlobalInfo *global_info,
sycl::handler &cgh,
Access::Write<CellDat<T> *> &a) {
inline T ***
create_loop_arg([[maybe_unused]] ParticleLoopGlobalInfo *global_info,
[[maybe_unused]] sycl::handler &cgh,
Access::Write<CellDat<T> *> &a) {
return a.obj->impl_get();
}
template <typename T>
inline T ***create_loop_arg(ParticleLoopGlobalInfo *global_info,
sycl::handler &cgh, Access::Add<CellDat<T> *> &a) {
inline T ***
create_loop_arg([[maybe_unused]] ParticleLoopGlobalInfo *global_info,
[[maybe_unused]] sycl::handler &cgh,
Access::Add<CellDat<T> *> &a) {
return a.obj->impl_get();
}
} // namespace ParticleLoopImplementation
Expand Down Expand Up @@ -260,7 +264,7 @@ template <typename T> class CellDat {
*/
inline CellDat(SYCLTargetSharedPtr sycl_target, const int ncells,
const int ncol)
: sycl_target(sycl_target), ncells(ncells), ncol(ncol), nrow_max(0) {
: nrow_max(0), sycl_target(sycl_target), ncells(ncells), ncol(ncol) {

this->nrow = std::vector<INT>(ncells);
this->d_ptr =
Expand Down
19 changes: 12 additions & 7 deletions include/neso_particles/containers/cell_dat_const.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ inline void create_kernel_arg(ParticleLoopIteration &iterationx,
*/
template <typename T>
inline CellDatConstDeviceTypeConst<T>
create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
create_loop_arg([[maybe_unused]] ParticleLoopGlobalInfo *global_info,
[[maybe_unused]] sycl::handler &cgh,
Access::Read<CellDatConst<T> *> &a) {
return a.obj->impl_get_const();
}
Expand All @@ -240,7 +241,8 @@ create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
*/
template <typename T>
inline CellDatConstDeviceType<T>
create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
create_loop_arg([[maybe_unused]] ParticleLoopGlobalInfo *global_info,
[[maybe_unused]] sycl::handler &cgh,
Access::Write<CellDatConst<T> *> &a) {
return a.obj->impl_get();
}
Expand All @@ -249,7 +251,8 @@ create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
*/
template <typename T>
inline CellDatConstDeviceType<T>
create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
create_loop_arg([[maybe_unused]] ParticleLoopGlobalInfo *global_info,
[[maybe_unused]] sycl::handler &cgh,
Access::Add<CellDatConst<T> *> &a) {
return a.obj->impl_get();
}
Expand All @@ -258,7 +261,8 @@ create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
*/
template <typename T>
inline CellDatConstDeviceType<T>
create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
create_loop_arg([[maybe_unused]] ParticleLoopGlobalInfo *global_info,
[[maybe_unused]] sycl::handler &cgh,
Access::Min<CellDatConst<T> *> &a) {
return a.obj->impl_get();
}
Expand All @@ -267,7 +271,8 @@ create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
*/
template <typename T>
inline CellDatConstDeviceType<T>
create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
create_loop_arg([[maybe_unused]] ParticleLoopGlobalInfo *global_info,
[[maybe_unused]] sycl::handler &cgh,
Access::Max<CellDatConst<T> *> &a) {
return a.obj->impl_get();
}
Expand Down Expand Up @@ -365,8 +370,8 @@ template <typename T> class CellDatConst {
*/
CellDatConst(SYCLTargetSharedPtr sycl_target, const int ncells,
const int nrow, const int ncol)
: sycl_target(sycl_target), ncells(ncells), nrow(nrow), ncol(ncol),
stride(nrow * ncol) {
: stride(nrow * ncol), sycl_target(sycl_target), ncells(ncells),
nrow(nrow), ncol(ncol) {
this->d_ptr =
sycl::malloc_device<T>(ncells * nrow * ncol, sycl_target->queue);
this->fill(0);
Expand Down
10 changes: 6 additions & 4 deletions include/neso_particles/containers/descendant_products.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ template <> struct KernelParameter<Access::Write<DescendantProducts>> {
/**
* Function to create the kernel argument for DescendantProducts write access.
*/
inline void create_kernel_arg(ParticleLoopIteration &iterationx,
DescendantProductsGet &rhs,
Access::DescendantProducts::Write &lhs) {
inline void
create_kernel_arg([[maybe_unused]] ParticleLoopIteration &iterationx,
DescendantProductsGet &rhs,
Access::DescendantProducts::Write &lhs) {
lhs.ptr_real = rhs.product_matrix_get.ptr_real;
lhs.ptr_int = rhs.product_matrix_get.ptr_int;
lhs.offsets_real = rhs.product_matrix_get.offsets_real;
Expand Down Expand Up @@ -210,7 +211,8 @@ namespace ParticleLoopImplementation {
* Method to compute access to a DescendantProducts (write)
*/
inline DescendantProductsGet
create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
create_loop_arg([[maybe_unused]] ParticleLoopGlobalInfo *global_info,
[[maybe_unused]] sycl::handler &cgh,
Access::Write<DescendantProducts *> &a) {
return a.obj->impl_get();
}
Expand Down
19 changes: 12 additions & 7 deletions include/neso_particles/containers/global_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,26 @@ template <typename T> struct KernelParameter<Access::Add<GlobalArray<T>>> {
* Function to create the kernel argument for GlobalArray read access.
*/
template <typename T>
inline void create_kernel_arg(ParticleLoopIteration &iterationx, T const *rhs,
Access::GlobalArray::Read<T> &lhs) {
inline void
create_kernel_arg([[maybe_unused]] ParticleLoopIteration &iterationx,
T const *rhs, Access::GlobalArray::Read<T> &lhs) {
lhs.ptr = rhs;
}
/**
* Function to create the kernel argument for GlobalArray add access.
*/
template <typename T>
inline void create_kernel_arg(ParticleLoopIteration &iterationx, T *rhs,
Access::GlobalArray::Add<T> &lhs) {
inline void
create_kernel_arg([[maybe_unused]] ParticleLoopIteration &iterationx, T *rhs,
Access::GlobalArray::Add<T> &lhs) {
lhs.ptr = rhs;
}

/**
* Post loop execution function for GlobalArray write.
*/
template <typename T>
inline void post_loop(ParticleLoopGlobalInfo *global_info,
inline void post_loop([[maybe_unused]] ParticleLoopGlobalInfo *global_info,
Access::Add<GlobalArray<T> *> &arg) {
arg.obj->impl_post_loop_add();
}
Expand All @@ -119,7 +121,8 @@ inline void post_loop(ParticleLoopGlobalInfo *global_info,
*/
template <typename T>
inline GlobalArrayImplGetConstT<T>
create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
create_loop_arg([[maybe_unused]] ParticleLoopGlobalInfo *global_info,
[[maybe_unused]] sycl::handler &cgh,
Access::Read<GlobalArray<T> *> &a) {
return a.obj->impl_get_const();
}
Expand All @@ -128,7 +131,8 @@ create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
*/
template <typename T>
inline GlobalArrayImplGetT<T>
create_loop_arg(ParticleLoopGlobalInfo *global_info, sycl::handler &cgh,
create_loop_arg([[maybe_unused]] ParticleLoopGlobalInfo *global_info,
[[maybe_unused]] sycl::handler &cgh,
Access::Add<GlobalArray<T> *> &a) {
return a.obj->impl_get();
}
Expand Down Expand Up @@ -205,6 +209,7 @@ template <typename T> class GlobalArray {
* Note that the copy operator creates shallow copies of the array.
*/
GlobalArray<T> &operator=(const GlobalArray<T> &) = default;
GlobalArray<T>(const GlobalArray<T> &) = default;

/**
* Create a new GlobalArray on a compute target and given size.
Expand Down
Loading

0 comments on commit e215503

Please sign in to comment.