Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion particle_structs/src/cabm/cabm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace pumipic {
typedef CabM_Input<DataTypes, MemSpace> Input_T;

//from https://github.com/SCOREC/Cabana/blob/53ad18a030f19e0956fd0cab77f62a9670f31941/core/src/CabanaM.hpp#L18-L19
using CM_DT = PS_DTBool<DataTypes>;
using CM_DT = PS_DTInt<DataTypes>;
using AoSoA_t = Cabana::AoSoA<CM_DT,memory_space>;

CabM(const CabM&) = delete;
Expand Down
6 changes: 3 additions & 3 deletions particle_structs/src/cabm/cabm_migrate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace pumipic {

// Count number of particles to send to each process
kkLidView num_send_particles("num_send_particles", comm_size + 1);
auto count_sending_particles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
auto count_sending_particles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
const lid_t process = new_process(particle_id);
if (mask && (process != comm_rank)) {
const lid_t process_index = dist.index(process);
Expand Down Expand Up @@ -88,7 +88,7 @@ namespace pumipic {
CreateViews<device_type, DataTypes>(send_particle, np_send);
kkLidView send_index(Kokkos::ViewAllocateWithoutInitializing("send_particle_index"), capacity());
auto element_to_gid_local = element_to_gid;
auto gatherParticlesToSend = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
auto gatherParticlesToSend = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
const lid_t process = new_process(particle_id);
if (mask && process != comm_rank) {
const lid_t process_index = dist.index(process);
Expand Down Expand Up @@ -196,7 +196,7 @@ namespace pumipic {
});

// ********** Set particles that were sent to non existent on this process *********
auto removeSentParticles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
auto removeSentParticles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
const bool sent = new_process(particle_id) != comm_rank;
const lid_t elm = new_element(particle_id);
// Subtract (its value + 1) to get to -1 if it was sent, 0 otherwise
Expand Down
4 changes: 2 additions & 2 deletions particle_structs/src/csr/CSR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ namespace pumipic {
const lid_t numPtcls = end-start;
Kokkos::parallel_for(Kokkos::TeamThreadRange(thread, numPtcls), [=] (lid_t& j) {
const lid_t particle_id = start+j;
bool mask = true;
lid_t mask = 1;
if (particle_id > num_ptcls_cpy)
mask = false;
mask = 0;
(*fn_d)(elm, particle_id, mask);
});
});
Expand Down
2 changes: 1 addition & 1 deletion particle_structs/src/csr/CSR_buildFns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace pumipic {

// atomic_fetch_add to increment from the beginning of each element
// when filling (offset[element] is start of element)
auto fill_ptcl_indices = PS_LAMBDA(const lid_t& elm_id, const lid_t& ptcl_id, bool& mask){
auto fill_ptcl_indices = PS_LAMBDA(const lid_t& elm_id, const lid_t& ptcl_id, lid_t& mask){
particle_indices(ptcl_id) = Kokkos::atomic_fetch_add(&row_indices(particle_elements(ptcl_id)),1);
};
parallel_for(fill_ptcl_indices);
Expand Down
4 changes: 2 additions & 2 deletions particle_structs/src/csr/CSR_migrate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace pumipic {

// Count number of particles to send to each process
kkLidView num_send_particles("num_send_particles", comm_size + 1);
auto count_sending_particles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
auto count_sending_particles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
const lid_t process = new_process(particle_id);
if (mask && (process != comm_rank)) {
const lid_t process_index = dist.index(process);
Expand Down Expand Up @@ -87,7 +87,7 @@ namespace pumipic {
CreateViews<device_type, DataTypes>(send_particle, np_send);
kkLidView send_index(Kokkos::ViewAllocateWithoutInitializing("send_particle_index"), capacity());
auto element_to_gid_local = element_to_gid;
auto gatherParticlesToSend = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
auto gatherParticlesToSend = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
const lid_t process = new_process(particle_id);
if (mask && process != comm_rank) {
const lid_t process_index = dist.index(process);
Expand Down
4 changes: 2 additions & 2 deletions particle_structs/src/csr/CSR_rebuild.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace pumipic {
kkLidView particles_per_element = kkLidView("particlesPerElement", num_elems+1);
kkLidView num_removed_d("num_removed_d",1);
// Fill ptcls per elem for existing ptcls
auto count_existing = PS_LAMBDA(const lid_t& elm_id, const lid_t& ptcl_id, const bool& mask) {
auto count_existing = PS_LAMBDA(const lid_t& elm_id, const lid_t& ptcl_id, const lid_t& mask) {
if (new_element[ptcl_id] > -1)
Kokkos::atomic_inc(&particles_per_element[new_element[ptcl_id]]);
else
Expand Down Expand Up @@ -56,7 +56,7 @@ namespace pumipic {
Kokkos::deep_copy(row_indices,offsets_new);
kkLidView new_indices(Kokkos::ViewAllocateWithoutInitializing("new indices"), new_element.size());

auto existing_ptcl_new_indices = PS_LAMBDA(const lid_t& elm_id, const lid_t& ptcl_id, const bool& mask) {
auto existing_ptcl_new_indices = PS_LAMBDA(const lid_t& elm_id, const lid_t& ptcl_id, const lid_t& mask) {
const lid_t new_elem = new_element[ptcl_id];
if (new_elem != -1)
new_indices[ptcl_id] = Kokkos::atomic_fetch_add(&row_indices(new_elem),1);
Expand Down
2 changes: 1 addition & 1 deletion particle_structs/src/dps/dps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace pumipic {
typedef Kokkos::UnorderedMap<gid_t, lid_t, device_type> GID_Mapping;
typedef DPS_Input<DataTypes, MemSpace> Input_T;

using DPS_DT = PS_DTBool<DataTypes>;
using DPS_DT = PS_DTInt<DataTypes>;
using AoSoA_t = Cabana::AoSoA<DPS_DT,memory_space>;

DPS(const DPS&) = delete;
Expand Down
6 changes: 3 additions & 3 deletions particle_structs/src/dps/dps_migrate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace pumipic {

// Count number of particles to send to each process
kkLidView num_send_particles("num_send_particles", comm_size + 1);
auto count_sending_particles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
auto count_sending_particles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
const lid_t process = new_process(particle_id);
if (mask && (process != comm_rank)) {
const lid_t process_index = dist.index(process);
Expand Down Expand Up @@ -87,7 +87,7 @@ namespace pumipic {
CreateViews<device_type, DataTypes>(send_particle, np_send);
kkLidView send_index(Kokkos::ViewAllocateWithoutInitializing("send_particle_index"), capacity());
auto element_to_gid_local = element_to_gid;
auto gatherParticlesToSend = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
auto gatherParticlesToSend = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
const lid_t process = new_process(particle_id);
if (mask && process != comm_rank) {
const lid_t process_index = dist.index(process);
Expand Down Expand Up @@ -193,7 +193,7 @@ namespace pumipic {
});

// ********** Set particles that were sent to non existent on this process *********
auto removeSentParticles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
auto removeSentParticles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
const bool sent = new_process(particle_id) != comm_rank;
const lid_t elm = new_element(particle_id);
// Subtract (its value + 1) to get to -1 if it was sent, 0 otherwise
Expand Down
2 changes: 1 addition & 1 deletion particle_structs/src/particle_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace pumipic {
typename std::remove_all_extents<DataType<M>>::type;

#ifdef PP_ENABLE_CAB
using PS_DT=PS_DTBool<Types>;
using PS_DT=PS_DTInt<Types>;
using soa_type = Cabana::SoA<PS_DT, vector_length>;
template <std::size_t N> using Slice =
Segment<DataType<N>, memory_space, Cabana::DefaultAccessMemory, vector_length,
Expand Down
4 changes: 2 additions & 2 deletions particle_structs/src/ps_for.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace pumipic {
void ParticleStructure<DataTypes, MemSpace>::getPIDs(ViewT& pids, ViewT& offsets) {
offsets = ViewT("offsets", num_elems+1);
ViewT ppe("ppe", num_elems+1);
auto setPPE = PS_LAMBDA(const lid_t& e, const lid_t& p, const bool& mask) {
auto setPPE = PS_LAMBDA(const lid_t& e, const lid_t& p, const lid_t& mask) {
if (mask) {
Kokkos::atomic_inc(&ppe(e));
}
Expand All @@ -75,7 +75,7 @@ namespace pumipic {

pids = ViewT("pids", getLastValue(offsets));
ViewT currIndex("currIndex", num_elems);
auto setPIDs = PS_LAMBDA(const lid_t& e, const lid_t& p, const bool& mask) {
auto setPIDs = PS_LAMBDA(const lid_t& e, const lid_t& p, const lid_t& mask) {
if (mask) {
auto index = Kokkos::atomic_fetch_add(&currIndex(e), 1);
pids(offsets(e)+index) = p;
Expand Down
4 changes: 2 additions & 2 deletions particle_structs/src/scs/SCS_buildFns.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace pumipic {
cap = getLastValue(offs);
}
template<class DataTypes, typename MemSpace>
void SellCSigma<DataTypes, MemSpace>::setupParticleMask(Kokkos::View<bool*> mask,
void SellCSigma<DataTypes, MemSpace>::setupParticleMask(Kokkos::View<lid_t*> mask,
kkLidView ptcls,
kkLidView chunk_widths,
kkLidView& chunk_starts) {
Expand Down Expand Up @@ -192,7 +192,7 @@ namespace pumipic {
if (element_id < ne)
mask(particle_id) = p < ptcls(row);
else
mask(particle_id) = false;
mask(particle_id) = 0;
});
});
});
Expand Down
6 changes: 3 additions & 3 deletions particle_structs/src/scs/SCS_migrate.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace pumipic {

//Count number of particles to send to each process
kkLidView num_send_particles("num_send_particles", comm_size + 1);
auto count_sending_particles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
auto count_sending_particles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
const lid_t process = new_process(particle_id);
if (mask && (process != comm_rank)) {
const lid_t process_index = dist.index(process);
Expand Down Expand Up @@ -80,7 +80,7 @@ namespace pumipic {
CreateViews<device_type, DataTypes>(send_particle, np_send);
kkLidView send_index(Kokkos::ViewAllocateWithoutInitializing("send_particle_index"), capacity());
auto element_to_gid_local = element_to_gid;
auto gatherParticlesToSend = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
auto gatherParticlesToSend = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
const lid_t process = new_process(particle_id);
if (mask && process != comm_rank) {
const lid_t process_index = dist.index(process);
Expand Down Expand Up @@ -187,7 +187,7 @@ namespace pumipic {
});

/********** Set particles that were sent to non existent on this process *********/
auto removeSentParticles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
auto removeSentParticles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
const bool sent = new_process(particle_id) != comm_rank;
const lid_t elm = new_element(particle_id);
//Subtract (its value + 1) to get to -1 if it was sent, 0 otherwise
Expand Down
26 changes: 13 additions & 13 deletions particle_structs/src/scs/SCS_rebuild.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace pumipic {
kkLidView num_holes_per_row("num_holes_per_row", numRows());
kkLidView element_to_row_local = element_to_row;
auto particle_mask_local = particle_mask;
auto countNewParticles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask){
auto countNewParticles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask){
const lid_t new_elem = new_element(particle_id);

const lid_t row = element_to_row_local(element_id);
Expand Down Expand Up @@ -52,14 +52,14 @@ namespace pumipic {
int num_moving_ptcls = getLastValue(offset_new_particles);
if (num_moving_ptcls == 0) {
Kokkos::parallel_reduce(capacity(), KOKKOS_LAMBDA(const lid_t& i, lid_t& sum) {
sum += static_cast<lid_t>(particle_mask_local(i));
sum += particle_mask_local(i);
}, num_ptcls);
return true;
}
kkLidView movingPtclIndices(Kokkos::ViewAllocateWithoutInitializing("movingPtclIndices"), num_moving_ptcls);
kkLidView isFromSCS("isFromSCS", num_moving_ptcls);
//Gather moving particle list
auto gatherMovingPtcls = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask){
auto gatherMovingPtcls = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask){
const lid_t new_elem = new_element(particle_id);

const lid_t row = element_to_row_local(element_id);
Expand All @@ -84,7 +84,7 @@ namespace pumipic {

//Assign hole index for moving particles
kkLidView holes(Kokkos::ViewAllocateWithoutInitializing("holeIndex"), num_moving_ptcls);
auto assignPtclsToHoles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask){
auto assignPtclsToHoles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask){
const lid_t row = element_to_row_local(element_id);
if (!mask) {
const lid_t moving_index = Kokkos::atomic_fetch_add(&(offset_new_particles(row)),1);
Expand All @@ -102,8 +102,8 @@ namespace pumipic {
const lid_t new_index = holes(i);
const lid_t fromSCS = isFromSCS(i);
if (fromSCS == 1)
particle_mask_local(old_index) = false;
particle_mask_local(new_index) = true;
particle_mask_local(old_index) = 0;
particle_mask_local(new_index) = 1;
});

//Shift SCS values
Expand All @@ -114,7 +114,7 @@ namespace pumipic {

//Count number of active particles
Kokkos::parallel_reduce(capacity(), KOKKOS_LAMBDA(const lid_t& i, lid_t& sum) {
sum += static_cast<lid_t>(particle_mask_local(i));
sum += particle_mask_local(i);
}, num_ptcls);
return true;
}
Expand All @@ -130,7 +130,7 @@ namespace pumipic {

//Count particles including new and leaving
kkLidView new_particles_per_elem("new_particles_per_elem", numRows());
auto countNewParticles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask){
auto countNewParticles = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask){
const lid_t new_elem = new_element(particle_id);
if (mask && new_elem != -1)
Kokkos::atomic_inc<lid_t>(&(new_particles_per_elem(new_elem)));
Expand Down Expand Up @@ -169,8 +169,8 @@ namespace pumipic {
if (activePtcls == 0) {
num_ptcls = 0;
auto local_mask = particle_mask;
auto resetMask = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
local_mask(particle_id) = false;
auto resetMask = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
local_mask(particle_id) = 0;
};
parallel_for(resetMask, "resetMask");

Expand Down Expand Up @@ -219,7 +219,7 @@ namespace pumipic {
new_capacity);

//Allocate the SCS
Kokkos::View<bool*, MemSpace> new_particle_mask("new_particle_mask", new_capacity);
Kokkos::View<lid_t*, MemSpace> new_particle_mask("new_particle_mask", new_capacity);
if (always_realloc || swap_size < new_capacity ||
swap_size * minimize_size < new_capacity) {
destroyViews<DataTypes, memory_space>(scs_data_swap);
Expand Down Expand Up @@ -249,7 +249,7 @@ namespace pumipic {
});
C_ = old_C;
kkLidView new_indices(Kokkos::ViewAllocateWithoutInitializing("new_scs_index"), capacity());
auto copySCS = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const bool& mask) {
auto copySCS = PS_LAMBDA(const lid_t& element_id, const lid_t& particle_id, const lid_t& mask) {
const lid_t new_elem = new_element(particle_id);
//TODO remove conditional
if (mask && new_elem != -1) {
Expand Down Expand Up @@ -281,7 +281,7 @@ namespace pumipic {
lid_t new_row = new_element_to_row(new_elem);
new_particle_indices(i) = Kokkos::atomic_fetch_add(&element_index(new_row), new_C);
lid_t new_index = new_particle_indices(i);
new_particle_mask(new_index) = true;
new_particle_mask(new_index) = 1;
});

if (new_particle_elements.size() > 0)
Expand Down
14 changes: 7 additions & 7 deletions particle_structs/src/scs/SellCSigma.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ template <std::size_t N> using Slice = Segment<DataType<N>, device_type>;
void createGlobalMapping(kkGidView elmGid, kkGidView& elm2Gid, GID_Mapping& elmGid2Lid);
void constructOffsets(lid_t nChunks, lid_t& nSlices, kkLidView chunk_widths,
kkLidView& offs, kkLidView& s2e, lid_t& capacity);
void setupParticleMask(Kokkos::View<bool*> mask, kkLidView ptcls, kkLidView chunk_widths,
void setupParticleMask(Kokkos::View<lid_t*> mask, kkLidView ptcls, kkLidView chunk_widths,
kkLidView& chunk_starts);
void initSCSData(kkLidView chunk_widths, kkLidView particle_elements,
MTVs particle_info);
Expand Down Expand Up @@ -186,7 +186,7 @@ template <std::size_t N> using Slice = Segment<DataType<N>, device_type>;
// it is a part of.
kkLidView slice_to_chunk;
//particle_mask true means there is a particle at this location, false otherwise
Kokkos::View<bool*, MemSpace> particle_mask;
Kokkos::View<lid_t*, MemSpace> particle_mask;
//offsets into the scs structure
kkLidView offsets;

Expand Down Expand Up @@ -263,7 +263,7 @@ void SellCSigma<DataTypes, MemSpace>::construct(kkLidView ptcls_per_elem,

//Allocate the SCS and backup with extra space
lid_t cap = capacity_;
particle_mask = Kokkos::View<bool*>(Kokkos::ViewAllocateWithoutInitializing("particle_mask"), cap);
particle_mask = Kokkos::View<lid_t*>(Kokkos::ViewAllocateWithoutInitializing("particle_mask"), cap);
if (extra_padding > 0)
cap *= (1 + extra_padding);
CreateViews<device_type, DataTypes>(ptcl_data, cap);
Expand Down Expand Up @@ -367,7 +367,7 @@ typename SellCSigma<DataTypes, MemSpace>::template Mirror<MSpace>* SellCSigma<Da
mirror_copy->slice_to_chunk = typename Mirror<MSpace>::kkLidView("mirror slice_to_chunk",
slice_to_chunk.size());
Kokkos::deep_copy(mirror_copy->slice_to_chunk, slice_to_chunk);
mirror_copy->particle_mask = Kokkos::View<bool*,MSpace>("mirror particle_mask",
mirror_copy->particle_mask = Kokkos::View<lid_t*,MSpace>("mirror particle_mask",
particle_mask.size());
Kokkos::deep_copy(mirror_copy->particle_mask, particle_mask);
mirror_copy->offsets = typename Mirror<MSpace>::kkLidView("mirror offsets", offsets.size());
Expand Down Expand Up @@ -407,7 +407,7 @@ void SellCSigma<DataTypes,MemSpace>::printFormat(const char* prefix) const {
kkGidHostMirror element_to_gid_host = deviceToHost(element_to_gid);
kkLidHostMirror row_to_element_host = deviceToHost(row_to_element);
kkLidHostMirror offsets_host = deviceToHost(offsets);
Kokkos::View<bool*>::host_mirror_type particle_mask_host = deviceToHost(particle_mask);
Kokkos::View<lid_t*>::host_mirror_type particle_mask_host = deviceToHost(particle_mask);

std::stringstream ss;
char buffer[1000];
Expand Down Expand Up @@ -486,7 +486,7 @@ void SellCSigma<DataTypes, MemSpace>::printMetrics(MPI_Comm mpi_comm) const {
lid_t np = 0;
for (lid_t p = 0; p < rowLen; ++p) {
const lid_t particle_id = start+(p*team_size);
const bool mask = particle_mask_cpy(particle_id);
const lid_t mask = particle_mask_cpy(particle_id);
np += !mask;
}
Kokkos::atomic_fetch_add(&padded_cells[0],np);
Expand Down Expand Up @@ -547,7 +547,7 @@ void SellCSigma<DataTypes, MemSpace>::parallel_for(FunctionType& fn, std::string
const lid_t element_id = row_to_element_cpy(row);
Kokkos::parallel_for(Kokkos::ThreadVectorRange(thread, rowLen), [=] (lid_t& p) {
const lid_t particle_id = start+(p*team_size);
const bool mask = particle_mask_cpy(particle_id);
const lid_t mask = particle_mask_cpy(particle_id);
(*fn_d)(element_id, particle_id, mask);
});
});
Expand Down
Loading