Commit 14d99d2a authored by kicici's avatar kicici

Renaming `_USE_HDF_` and other macros.

C++ reserves all names starting with `_X` for some capital letter `X`.
Instead, use `CUBISM_` prefix.
Cubism still accepts all macros, but pops out a warning if used.
parent 9ab57e26
#ifndef CUBISM_H
#define CUBISM_H
#ifdef _USE_NUMA_
#warning _USE_NUMA_ is deprecated, use CUBISM_USE_NUMA instead.
#define CUBISM_USE_NUMA
#endif
#ifdef _ON_FERMI_
#warning _ON_FERMI_ is deprecated, use CUBISM_ON_FERMI instead.
#define CUBISM_ON_FERMI
#endif
#ifndef CUBISM_NAMESPACE_BEGIN
#define CUBISM_NAMESPACE_BEGIN namespace cubism {
#endif
......
......@@ -14,7 +14,7 @@
#include <cassert>
#include <algorithm>
#ifdef _USE_NUMA_
#ifdef CUBISM_USE_NUMA
#include <numa.h>
#include <omp.h>
#endif
......@@ -67,7 +67,7 @@ protected:
//numa touch
#pragma omp parallel
{
#ifdef _USE_NUMA_
#ifdef CUBISM_USE_NUMA
const int cores_per_node = numa_num_configured_cpus() / numa_num_configured_nodes();
const int mynode = omp_get_thread_num() / cores_per_node;
numa_run_on_node(mynode);
......
......@@ -14,14 +14,19 @@
#include <utility>
#ifdef _USE_HDF_
#include <hdf5.h>
#warning _USE_HDF_ is deprecated, use CUBISM_USE_HDF instead.
#define CUBISM_USE_HDF
#endif
#ifdef CUBISM_USE_HDF
#include <hdf5.h>
// Function to retrieve HDF5 type (hid_t) for a given real type.
// If using custom types, the user should specialize this function.
template <typename T> hid_t get_hdf5_type();
template <> inline hid_t get_hdf5_type<float>() { return H5T_NATIVE_FLOAT; }
template <> inline hid_t get_hdf5_type<double>() { return H5T_NATIVE_DOUBLE; }
#endif
#include "BlockInfo.h"
#include "MeshMap.h"
......@@ -40,7 +45,7 @@ void DumpHDF5(const TGrid &grid,
const std::string &dpath = ".",
const bool bXMF = true)
{
#ifdef _USE_HDF_
#ifdef CUBISM_USE_HDF
typedef typename TGrid::BlockType B;
// fname is the base filepath tail without file type extension and
......@@ -80,7 +85,7 @@ void DumpHDF5(const TGrid &grid,
hsize_t dim[1] = {vertices.size()};
fspace_id = H5Screate_simple(1, dim, NULL);
#ifndef _ON_FERMI_
#ifndef CUBISM_ON_FERMI
dataset_id = H5Dcreate(file_id, dset_name[i].c_str(), H5T_NATIVE_DOUBLE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#else
dataset_id = H5Dcreate2(file_id, dset_name[i].c_str(), H5T_NATIVE_DOUBLE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......@@ -135,7 +140,7 @@ void DumpHDF5(const TGrid &grid,
fapl_id = H5Pcreate(H5P_DATASET_XFER);
fspace_id = H5Screate_simple(4, dims, NULL);
#ifndef _ON_FERMI_
#ifndef CUBISM_ON_FERMI
dataset_id = H5Dcreate(file_id, "data", get_hdf5_type<hdf5Real>(), fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#else
dataset_id = H5Dcreate2(file_id, "data", get_hdf5_type<hdf5Real>(), fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......@@ -200,7 +205,7 @@ void DumpHDF5(const TGrid &grid,
template<typename TStreamer, typename hdf5Real, typename TGrid>
void ReadHDF5(TGrid &grid, const std::string fname, const std::string dpath=".")
{
#ifdef _USE_HDF_
#ifdef CUBISM_USE_HDF
typedef typename TGrid::BlockType B;
// fname is the base filepath tail without file type extension and
......
......@@ -34,7 +34,7 @@ void DumpHDF5_MPI(const TGrid &grid,
const std::string &dpath = ".",
const bool bXMF = true)
{
#ifdef _USE_HDF_
#ifdef CUBISM_USE_HDF
typedef typename TGrid::BlockType B;
int rank;
......@@ -81,7 +81,7 @@ void DumpHDF5_MPI(const TGrid &grid,
hsize_t dim[1] = {vertices.size()};
fspace_id = H5Screate_simple(1, dim, NULL);
#ifndef _ON_FERMI_
#ifndef CUBISM_ON_FERMI
dataset_id = H5Dcreate(file_id, dset_name[i].c_str(), H5T_NATIVE_DOUBLE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#else
dataset_id = H5Dcreate2(file_id, dset_name[i].c_str(), H5T_NATIVE_DOUBLE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......@@ -179,7 +179,7 @@ void DumpHDF5_MPI(const TGrid &grid,
H5Pset_dxpl_mpio(fapl_id, H5FD_MPIO_COLLECTIVE);
fspace_id = H5Screate_simple(4, dims, NULL);
#ifndef _ON_FERMI_
#ifndef CUBISM_ON_FERMI
dataset_id = H5Dcreate(file_id, "data", get_hdf5_type<hdf5Real>(), fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#else
dataset_id = H5Dcreate2(file_id, "data", get_hdf5_type<hdf5Real>(), fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......@@ -240,7 +240,7 @@ void DumpHDF5_MPI(const TGrid &grid,
template<typename TStreamer, typename hdf5Real, typename TGrid>
void ReadHDF5_MPI(TGrid &grid, const std::string fname, const std::string dpath=".")
{
#ifdef _USE_HDF_
#ifdef CUBISM_USE_HDF
typedef typename TGrid::BlockType B;
int rank;
......
......@@ -311,7 +311,7 @@ void DumpSliceHDF5(const TSlice& slice,
const std::string &dpath = ".",
const bool bXMF = true)
{
#ifdef _USE_HDF_
#ifdef CUBISM_USE_HDF
typedef typename TSlice::GridType::BlockType B;
static const unsigned int NCHANNELS = TStreamer::NCHANNELS;
......@@ -355,7 +355,7 @@ void DumpSliceHDF5(const TSlice& slice,
hsize_t dim[1] = {vertices.size()};
fspace_id = H5Screate_simple(1, dim, NULL);
#ifndef _ON_FERMI_
#ifndef CUBISM_ON_FERMI
dataset_id = H5Dcreate(file_id, dset_name[i].c_str(), H5T_NATIVE_DOUBLE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#else
dataset_id = H5Dcreate2(file_id, dset_name[i].c_str(), H5T_NATIVE_DOUBLE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......@@ -387,7 +387,7 @@ void DumpSliceHDF5(const TSlice& slice,
fapl_id = H5Pcreate(H5P_DATASET_XFER);
fspace_id = H5Screate_simple(3, dims, NULL);
#ifndef _ON_FERMI_
#ifndef CUBISM_ON_FERMI
dataset_id = H5Dcreate(file_id, "data", get_hdf5_type<hdf5Real>(), fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#else
dataset_id = H5Dcreate2(file_id, "data", get_hdf5_type<hdf5Real>(), fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......
......@@ -112,7 +112,7 @@ void DumpSliceHDF5MPI(const TSlice& slice,
const std::string &dpath = ".",
const bool bXMF = true)
{
#ifdef _USE_HDF_
#ifdef CUBISM_USE_HDF
typedef typename TSlice::GridType::BlockType B;
// fname is the base filepath tail without file type extension and
......@@ -157,7 +157,7 @@ void DumpSliceHDF5MPI(const TSlice& slice,
hsize_t dim[1] = {vertices.size()};
fspace_id = H5Screate_simple(1, dim, NULL);
#ifndef _ON_FERMI_
#ifndef CUBISM_ON_FERMI
dataset_id = H5Dcreate(file_id, dset_name[i].c_str(), H5T_NATIVE_DOUBLE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#else
dataset_id = H5Dcreate2(file_id, dset_name[i].c_str(), H5T_NATIVE_DOUBLE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......@@ -218,7 +218,7 @@ void DumpSliceHDF5MPI(const TSlice& slice,
H5Pset_dxpl_mpio(fapl_id, H5FD_MPIO_COLLECTIVE);
fspace_id = H5Screate_simple(3, dims, NULL);
#ifndef _ON_FERMI_
#ifndef CUBISM_ON_FERMI
dataset_id = H5Dcreate(file_id, "data", get_hdf5_type<hdf5Real>(), fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#else
dataset_id = H5Dcreate2(file_id, "data", get_hdf5_type<hdf5Real>(), fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......
......@@ -303,7 +303,7 @@ void DumpSubdomainHDF5(const TSubdomain& subdomain,
const std::string &dpath = ".",
const bool bXMF = true)
{
#ifdef _USE_HDF_
#ifdef CUBISM_USE_HDF
typedef typename TSubdomain::GridType::BlockType B;
// fname is the base filepath tail without file type extension and
......@@ -342,7 +342,7 @@ void DumpSubdomainHDF5(const TSubdomain& subdomain,
hsize_t dim[1] = {vertices.size()};
fspace_id = H5Screate_simple(1, dim, NULL);
#ifndef _ON_FERMI_
#ifndef CUBISM_ON_FERMI
dataset_id = H5Dcreate(file_id, dset_name[i].c_str(), H5T_NATIVE_DOUBLE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#else
dataset_id = H5Dcreate2(file_id, dset_name[i].c_str(), H5T_NATIVE_DOUBLE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......@@ -426,7 +426,7 @@ void DumpSubdomainHDF5(const TSubdomain& subdomain,
fapl_id = H5Pcreate(H5P_DATASET_XFER);
fspace_id = H5Screate_simple(4, dims, NULL);
#ifndef _ON_FERMI_
#ifndef CUBISM_ON_FERMI
dataset_id = H5Dcreate(file_id, "data", get_hdf5_type<hdf5Real>(), fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#else
dataset_id = H5Dcreate2(file_id, "data", get_hdf5_type<hdf5Real>(), fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......
......@@ -147,7 +147,7 @@ void DumpSubdomainHDF5MPI(const TSubdomain& subdomain,
const std::string &dpath = ".",
const bool bXMF = true)
{
#ifdef _USE_HDF_
#ifdef CUBISM_USE_HDF
typedef typename TSubdomain::GridType::BlockType B;
int rank;
......@@ -191,7 +191,7 @@ void DumpSubdomainHDF5MPI(const TSubdomain& subdomain,
hsize_t dim[1] = {vertices.size()};
fspace_id = H5Screate_simple(1, dim, NULL);
#ifndef _ON_FERMI_
#ifndef CUBISM_ON_FERMI
dataset_id = H5Dcreate(file_id, dset_name[i].c_str(), H5T_NATIVE_DOUBLE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#else
dataset_id = H5Dcreate2(file_id, dset_name[i].c_str(), H5T_NATIVE_DOUBLE, fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......@@ -305,7 +305,7 @@ void DumpSubdomainHDF5MPI(const TSubdomain& subdomain,
H5Pset_dxpl_mpio(fapl_id, H5FD_MPIO_COLLECTIVE);
fspace_id = H5Screate_simple(4, dims, NULL);
#ifndef _ON_FERMI_
#ifndef CUBISM_ON_FERMI
dataset_id = H5Dcreate(file_id, "data", get_hdf5_type<hdf5Real>(), fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#else
dataset_id = H5Dcreate2(file_id, "data", get_hdf5_type<hdf5Real>(), fspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
......
......@@ -6,11 +6,11 @@
#ifndef COMMON_H_QLCQRKJP
#define COMMON_H_QLCQRKJP
#ifdef _DOUBLE_
#ifdef CUBISM_TEST_DOUBLE
using MyReal = double;
#else
using MyReal = float;
#endif /* _DOUBLE_ */
#endif /* CUBISM_TEST_DOUBLE */
constexpr int BLOCK_SIZE = 16;
......
......@@ -29,15 +29,15 @@ $(warning using precision=$(precision))
$(warning using hdf5precision=$(hdf5precision))
$(warning using nonuniform=$(nonuniform))
ifeq ("$(precision)","double")
CFLAGS += -D_DOUBLE_
CFLAGS += -DCUBISM_TEST_DOUBLE
endif
ifeq ("$(hdf5precision)","double")
CFLAGS += -D_HDF5_DOUBLE_PRECISION_
CFLAGS += -DCUBISM_TEST_HDF5_DOUBLE_PRECISION
endif
ifeq ("$(nonuniform)","yes")
CFLAGS += -D_NONUNIFORM_
CFLAGS += -DCUBISM_TEST__NONUNIFORM
endif
all: testDumpsMPI.cpp
......
......@@ -12,7 +12,7 @@
#include "Cubism/GridMPI.h"
#include "Cubism/MeshMap.h"
#define _USE_HDF_
#define CUBISM_USE_HDF
#include "Cubism/HDF5Dumper.h"
#include "Cubism/HDF5Dumper_MPI.h"
......@@ -31,7 +31,7 @@ using namespace cubism;
using namespace std;
// dumpers
#ifndef _HDF5_DOUBLE_PRECISION_
#ifndef CUBISM_TEST_HDF5_DOUBLE_PRECISION
typedef float hdf5Real;
const string prec_string = "4byte";
#else
......@@ -47,10 +47,10 @@ using MySlice = typename SliceTypes::Slice<MyGrid>;
using MySliceMPI = typename SliceTypesMPI::Slice<MyGridMPI>;
using MySubdomain = typename SubdomainTypes::Subdomain<MyGrid>;
using MySubdomainMPI = typename SubdomainTypesMPI::Subdomain<MyGridMPI>;
#ifdef _NONUNIFORM_
#ifdef CUBISM_TEST_NONUNIFORM
using MyMeshMap = MeshMap<MyBlock>;
using MyDensity = RandomDensity;
#endif /* _NONUNIFORM_ */
#endif /* CUBISM_TEST_NONUNIFORM */
int main(int argc, char* argv[])
......@@ -69,7 +69,7 @@ int main(int argc, char* argv[])
const int ppdy = parser("ppdy").asInt(ppdx);
const int ppdz = parser("ppdz").asInt(ppdx);
#ifdef _NONUNIFORM_
#ifdef CUBISM_TEST_NONUNIFORM
MyDensity mesh_density;
MyMeshMap* xmap = new MyMeshMap(0, 1, ppdx * bpdx);
MyMeshMap* ymap = new MyMeshMap(0, 1, ppdy * bpdy);
......@@ -80,7 +80,7 @@ int main(int argc, char* argv[])
MyGridMPI* grid = new MyGridMPI(xmap, ymap, zmap, ppdx, ppdy, ppdz, bpdx, bpdy, bpdz);
#else
MyGridMPI* grid = new MyGridMPI(ppdx, ppdy, ppdz, bpdx, bpdy, bpdz);
#endif /* _NONUNIFORM_ */
#endif /* CUBISM_TEST_NONUNIFORM */
int myrank;
const MPI_Comm comm = grid->getCartComm();
......
......@@ -22,11 +22,11 @@ CFLAGS+= -Wpedantic -Wno-unused-parameter # does not make much sense with functi
$(warning using precision=$(precision))
$(warning using nonuniform=$(nonuniform))
ifeq ("$(precision)","double")
CFLAGS += -D_DOUBLE_
CFLAGS += -DCUBISM_TEST_DOUBLE
endif
ifeq ("$(nonuniform)","yes")
CFLAGS += -D_NONUNIFORM_
CFLAGS += -DCUBISM_TEST_NONUNIFORM
endif
all: testSynchronizerMPI.cpp
......
......@@ -20,10 +20,10 @@ using namespace std;
using MyBlock = Block<MyReal,32>;
using MyGrid = Grid<MyBlock>;
using MyGridMPI = GridMPI<MyGrid>;
#ifdef _NONUNIFORM_
#ifdef CUBISM_TEST_NONUNIFORM
using MyMeshMap = MeshMap<MyBlock>;
using MyDensity = UniformDensity;
#endif /* _NONUNIFORM_ */
#endif /* CUBISM_TEST_NONUNIFORM */
template<typename TKernel, typename TGrid>
......@@ -86,7 +86,7 @@ int main(int argc, char* argv[])
const int ppdy = parser("ppdy").asInt(ppdx);
const int ppdz = parser("ppdz").asInt(ppdx);
#ifdef _NONUNIFORM_
#ifdef CUBISM_TEST_NONUNIFORM
MyDensity mesh_density;
MyMeshMap* xmap = new MyMeshMap(0, 1, ppdx * bpdx);
MyMeshMap* ymap = new MyMeshMap(0, 1, ppdy * bpdy);
......@@ -97,7 +97,7 @@ int main(int argc, char* argv[])
MyGridMPI* grid = new MyGridMPI(xmap, ymap, zmap, ppdx, ppdy, ppdz, bpdx, bpdy, bpdz);
#else
MyGridMPI* grid = new MyGridMPI(ppdx, ppdy, ppdz, bpdx, bpdy, bpdz);
#endif /* _NONUNIFORM_ */
#endif /* CUBISM_TEST_NONUNIFORM */
int myrank;
const MPI_Comm comm = grid->getCartComm();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment