Skip to content

Commit

Permalink
replace all stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelyr committed Nov 15, 2024
1 parent ca72e8b commit ab85e4f
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 43 deletions.
1 change: 0 additions & 1 deletion particle_structs/src/cabm/cabm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "psMemberTypeCabana.h"
#include "cabm_input.hpp"
#include <sstream>
#include "ppPrint.h"

namespace pumipic {

Expand Down
2 changes: 1 addition & 1 deletion particle_structs/src/csr/CSR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ namespace pumipic {
template <class MSpace>
typename CSR<DataTypes, MemSpace>::template Mirror<MSpace>* CSR<DataTypes, MemSpace>::copy() {
if (std::is_same<memory_space, typename MSpace::memory_space>::value) {
fprintf(stderr, "[ERROR] Copy to same memory space not supported\n");
pPrintError( "[ERROR] Copy to same memory space not supported\n");
exit(EXIT_FAILURE);
}
Mirror<MSpace>* mirror_copy = new CSR<DataTypes, MSpace>();
Expand Down
4 changes: 2 additions & 2 deletions particle_structs/src/csr/CSR_buildFns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace pumipic {
MPI_Comm_rank(mpi_comm, &comm_rank);

if(!comm_rank)
fprintf(stderr, "Building CSR\n");
pPrintError( "Building CSR\n");

// SS1 allocate the offsets array and use an exclusive_scan (aka prefix sum)
// to fill the entries of the offsets array.
Expand All @@ -85,7 +85,7 @@ namespace pumipic {
// If particle info is provided then enter the information
lid_t given_particles = particle_elements.size();
if (given_particles > 0 && particle_info != NULL) {
if(!comm_rank) fprintf(stderr, "initializing CSR data\n");
if(!comm_rank) pPrintError( "initializing CSR data\n");
initCsrData(particle_elements, particle_info);
}

Expand Down
8 changes: 4 additions & 4 deletions particle_structs/src/dps/dps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ namespace pumipic {
int comm_rank;
MPI_Comm_rank(mpi_comm, &comm_rank);
if(!comm_rank)
fprintf(stderr, "building DPS\n");
pPrintError( "building DPS\n");

// calculate num_soa_ from number of particles + extra padding
num_soa_ = Kokkos::ceil(Kokkos::ceil(double(num_ptcls)/AoSoA_t::vector_length)*(1+extra_padding));
Expand All @@ -145,7 +145,7 @@ namespace pumipic {
createGlobalMapping(element_gids, element_to_gid, element_gid_to_lid);
// populate AoSoA with input data if given
if (particle_elements.size() > 0 && particle_info != NULL) {
if(!comm_rank) fprintf(stderr, "initializing DPS data\n");
if(!comm_rank) pPrintError( "initializing DPS data\n");
fillAoSoA(particle_elements, particle_info, parentElms_); // fill aosoa with data
}
else
Expand Down Expand Up @@ -242,7 +242,7 @@ namespace pumipic {
template <class MSpace>
typename DPS<DataTypes, MemSpace>::template Mirror<MSpace>* DPS<DataTypes, MemSpace>::copy() {
if (std::is_same<memory_space, typename MSpace::memory_space>::value) {
fprintf(stderr, "[ERROR] Copy to same memory space not supported\n");
pPrintError( "[ERROR] Copy to same memory space not supported\n");
exit(EXIT_FAILURE);
}
Mirror<MSpace>* mirror_copy = new DPS<DataTypes, MSpace>();
Expand Down Expand Up @@ -410,7 +410,7 @@ namespace pumipic {
Mirror<MSpace>* copy() {reportError(); return NULL;}

private:
void reportError() const {fprintf(stderr, "[ERROR] pumi-pic was built "
void reportError() const {pPrintError( "[ERROR] pumi-pic was built "
"without Cabana so the DPS structure "
"can not be used\n");}
};
Expand Down
1 change: 1 addition & 0 deletions particle_structs/src/particle_structs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
#include <cabm.hpp>
#include <dps.hpp>
#include "psMemberType.h"
#include "ppPrint.h"
4 changes: 2 additions & 2 deletions particle_structs/src/ps_for.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace pumipic {
dps->parallel_for(fn, s);
return;
}
fprintf(stderr, "[ERROR] Structure does not support parallel for used on kernel %s\n",
pPrintError( "[ERROR] Structure does not support parallel for used on kernel %s\n",
s.c_str());
throw 1;
}
Expand All @@ -49,7 +49,7 @@ namespace pumipic {
return dps->template copy<MSpace>();
}

fprintf(stderr, "[ERROR] Structure does not support copy\n");
pPrintError( "[ERROR] Structure does not support copy\n");
throw 1;
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion particle_structs/src/scs/SCS_rebuild.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ namespace pumipic {
});
auto hasInactivePtcls_h = deviceToHost(hasInactivePtcls);
if( hasInactivePtcls_h(0) ) {
fprintf(stderr, "[ERROR] there are new particles being added that are marked"
pPrintError( "[ERROR] there are new particles being added that are marked"
"as inactive (element id set to -1)\n");
exit(EXIT_FAILURE);
}
Expand Down
4 changes: 2 additions & 2 deletions particle_structs/src/scs/SellCSigma.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void SellCSigma<DataTypes, MemSpace>::construct(kkLidView ptcls_per_elem,
C_ = chooseChunkHeight(C_max, ptcls_per_elem);

if(!comm_rank)
fprintf(stderr, "Building SCS with C: %d sigma: %d V: %d\n",C_,sigma,V_);
pPrintError( "Building SCS with C: %d sigma: %d V: %d\n",C_,sigma,V_);
//Perform sorting
kkLidView ptcls;
kkLidView index;
Expand Down Expand Up @@ -337,7 +337,7 @@ template<class DataTypes, typename MemSpace>
template <class MSpace>
typename SellCSigma<DataTypes, MemSpace>::template Mirror<MSpace>* SellCSigma<DataTypes, MemSpace>::copy() {
if (std::is_same<memory_space, typename MSpace::memory_space>::value) {
fprintf(stderr, "[ERROR] Copy to same memory space not supported\n");
pPrintError( "[ERROR] Copy to same memory space not supported\n");
exit(EXIT_FAILURE);
}
const auto cmax = maxChunk<MSpace>(C_max);
Expand Down
3 changes: 2 additions & 1 deletion particle_structs/src/support/MemberTypeLibraries.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <Kokkos_Core.hpp>
#include <mpi.h>
#include <cstdlib>
#include "ppPrint.h"

namespace pumipic {

Expand Down Expand Up @@ -162,7 +163,7 @@ namespace pumipic {
});
auto hasFailed_h = deviceToHost(hasFailed);
if( hasFailed_h(0) ) {
fprintf(stderr, "[ERROR] index out of range in view-to-view copy\n");
pPrintError( "[ERROR] index out of range in view-to-view copy\n");
exit(EXIT_FAILURE);
}
CopyViewsToViewsImpl<View, Types...>(dsts+1, srcs+1, ps_indices);
Expand Down
12 changes: 6 additions & 6 deletions src/pumipic_adjacency.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,12 @@ bool search_mesh_3d(o::Mesh& mesh, // (in) mesh
}
};
parallel_for(ptcls, ptclsNotFound, "ptclsNotFound");
fprintf(stderr, "ERROR:loop limit %d exceeded\n", looplimit);
pPrintError( "ERROR:loop limit %d exceeded\n", looplimit);
break;
}
} //while
Kokkos::Profiling::popRegion(); //whole
//fprintf(stderr, "loop-time seconds %f\n", timer.seconds());
//pPrintError( "loop-time seconds %f\n", timer.seconds());
pumipic::RecordTime("Search Mesh 3d", timer.seconds(), btime);
return found;
}
Expand Down Expand Up @@ -600,7 +600,7 @@ bool search_mesh(o::Mesh& mesh, ParticleStructure< ParticleType >* ptcls,
int loops = 0;
while(!found) {
if(debug) {
fprintf(stderr, "------------ %d ------------\n", loops);
pPrintError( "------------ %d ------------\n", loops);
}
//pid is same for a particle between iterations in this while loop
auto lamb = PS_LAMBDA(const int& e, const int& pid, const int& mask) {
Expand Down Expand Up @@ -755,13 +755,13 @@ bool search_mesh(o::Mesh& mesh, ParticleStructure< ParticleType >* ptcls,

if(looplimit && loops > looplimit) {
//if (debug)
fprintf(stderr, "ERROR:loop limit %d exceeded\n", looplimit);
pPrintError( "ERROR:loop limit %d exceeded\n", looplimit);
break;
}
} //while

if(debug)
fprintf(stderr, "\t: loops %d\n", loops);
pPrintError( "\t: loops %d\n", loops);
Kokkos::Profiling::popRegion();
return found;
}
Expand Down Expand Up @@ -1139,7 +1139,7 @@ bool search_mesh_2d(o::Mesh& mesh, // (in) mesh
};
ps::parallel_for(ptcls, ptclsNotFound, "ptclsNotFound");
Omega_h::HostWrite<o::LO> numNotFound_h(numNotFound);
fprintf(stderr, "ERROR:Rank %d: loop limit %d exceeded. %d %s were "
pPrintError( "ERROR:Rank %d: loop limit %d exceeded. %d %s were "
"not found. Deleting them...\n", rank, looplimit, numNotFound_h[0],
ptcls->getName().c_str());
break;
Expand Down
4 changes: 2 additions & 2 deletions src/pumipic_adjacency.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ namespace pumipic {
}
Omega_h::HostWrite<o::LO> numNotInElem_h(numNotInElem);
if (numNotInElem_h[0] > 0) {
fprintf(stderr, "[WARNING] Rank %d: %d particles are not located in their "
pPrintError( "[WARNING] Rank %d: %d particles are not located in their "
"starting elements. Deleting them...\n", rank, numNotInElem_h[0]);
}
return numNotInElem_h[0];
Expand Down Expand Up @@ -531,7 +531,7 @@ namespace pumipic {
};
ps::parallel_for(ptcls, ptclsNotFound, "ptclsNotFound");
Omega_h::HostWrite<o::LO> numNotFound_h(numNotFound);
fprintf(stderr, "ERROR:Rank %d: loop limit %d exceeded. %d particles were "
pPrintError( "ERROR:Rank %d: loop limit %d exceeded. %d particles were "
"not found. Deleting them...\n", rank, looplimit, numNotFound_h[0]);
break;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pumipic_comm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <Omega_h_array_ops.hpp>
#include <mpi.h>
#include <Omega_h_comm.hpp>
#include "ppPrint.h"

using Omega_h::MpiTraits;

Expand Down Expand Up @@ -224,7 +225,7 @@ namespace pumipic {
int ne = nents(edim);
int nvals = length / ne;
if (ne*nvals != length) {
fprintf(stderr, "Comm array size does not match the expected size for dimension %d\n",edim);
pPrintError( "Comm array size does not match the expected size for dimension %d\n",edim);
return;
}
if (commptr->size() == 1)
Expand Down
8 changes: 4 additions & 4 deletions src/pumipic_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace pumipic {
if (comm->rank() == 0) {
if (!Omega_h::filesystem::exists(dir)) {
if (!Omega_h::filesystem::create_directory(dir)) {
fprintf(stderr, "[ERROR] Failed to create directory %s\n", dir);
pPrintError( "[ERROR] Failed to create directory %s\n", dir);
return;
}
}
Expand All @@ -70,7 +70,7 @@ namespace pumipic {
//Write file for the pumipic mesh data
std::ofstream out_str(ppm_file);
if (!out_str) {
fprintf(stderr, "[ERROR] Failed to open file %s\n", ppm_file);
pPrintError( "[ERROR] Failed to open file %s\n", ppm_file);
return;
}
#ifdef OMEGA_H_USE_ZLIB
Expand Down Expand Up @@ -122,7 +122,7 @@ namespace pumipic {
sprintf(dir, "%s_%d.ppm", path, comm->size());

if (!Omega_h::filesystem::exists(dir)) {
fprintf(stderr, "[ERROR] Directory %s does not exist\n", dir);
pPrintError( "[ERROR] Directory %s does not exist\n", dir);
return;
}

Expand All @@ -136,7 +136,7 @@ namespace pumipic {

std::ifstream in_str(ppm_file);
if (!in_str) {
fprintf(stderr, "[ERROR] Cannot open file %s\n", ppm_file);
pPrintError( "[ERROR] Cannot open file %s\n", ppm_file);
return;
}

Expand Down
9 changes: 5 additions & 4 deletions src/pumipic_input.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "pumipic_input.hpp"
#include <fstream>
#include <stdexcept>
#include "ppPrint.h"

namespace {
std::string getMethodString(pumipic::Input::Method m) {
Expand Down Expand Up @@ -36,7 +37,7 @@ namespace pumipic {
while (dot >=0 && partition_filename[dot] != '.')
--dot;
if (dot < 0) {
fprintf(stderr, "[ERROR] Filename provided has no extension (%s)", partition_filename);
pPrintError( "[ERROR] Filename provided has no extension (%s)", partition_filename);
throw std::runtime_error("Filename has no extension");
}
char* extension = partition_filename + dot + 1;
Expand All @@ -45,7 +46,7 @@ namespace pumipic {
std::ifstream in_str(partition_filename);
if (!in_str) {
if (!comm_rank)
fprintf(stderr,"Cannot open file %s\n", partition_filename);
pPrintError("Cannot open file %s\n", partition_filename);
throw std::runtime_error("Cannot open file");
}
int own;
Expand All @@ -61,7 +62,7 @@ namespace pumipic {
std::ifstream in_str(partition_filename);
if (!in_str) {
if (!comm_rank)
fprintf(stderr,"Cannot open file %s\n", partition_filename);
pPrintError("Cannot open file %s\n", partition_filename);
throw std::runtime_error("Cannot open file");
}
int size;
Expand All @@ -87,7 +88,7 @@ namespace pumipic {

}
else {
fprintf(stderr, "[ERROR] Only .ptn and .cpn partitions are supported");
pPrintError( "[ERROR] Only .ptn and .cpn partitions are supported");
throw std::runtime_error("Invalid partition file extension");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pumipic_lb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ namespace pumipic {
ptr += sprintf(ptr," %d", *pitr);
}
ptr += sprintf(ptr, "]\n");
fprintf(stderr, "%s", error);
pPrintError( "%s", error);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/pumipic_part_construct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace pumipic {
int comm_size = comm->size();
if (ghost_layers < safe_layers) {
if (!rank)
fprintf(stderr, "Ghost layers must be >= safe layers");
pPrintError( "Ghost layers must be >= safe layers");
throw 1;
}
is_full_mesh = false;
Expand Down Expand Up @@ -230,7 +230,7 @@ namespace pumipic {
picpart->add_coords(new_coords);
Omega_h::finalize_classification(picpart);
if(!picpart->nelems()) {
fprintf(stderr,"%s: empty part on rank %d\n", __func__, rank);
pPrintError("%s: empty part on rank %d\n", __func__, rank);
}
assert(picpart->nelems());

Expand Down Expand Up @@ -295,7 +295,7 @@ namespace {
Omega_h::parallel_for(m.nelems(), ownByClassification, "ownByClassification");
Omega_h::HostWrite<Omega_h::LO> selfcount_h(selfcount);
if(!selfcount_h[0]) {
fprintf(stderr, "%s rank %d with no owned elements detected\n", __func__, self);
pumipic::pPrintError( "%s rank %d with no owned elements detected\n", __func__, self);
}
assert(selfcount_h[0]);
}
Expand Down
3 changes: 2 additions & 1 deletion support/ppAssert.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "ppAssert.h"
#include <cstdio>
#include <cstdlib>
#include "ppPrint.h"

namespace pumipic {

// borrowed from:
// https://github.com/SCOREC/core/blob/2472c570dc3a9e5acc23146288822733759558a1/pcu/pcu_util.[h|c]
void Assert_Fail(const char* msg) {
fprintf(stderr, "%s", msg);
pPrintError( "%s", msg);
abort();
}

Expand Down
Loading

0 comments on commit ab85e4f

Please sign in to comment.