Commit 4bbe1a66 authored by kicici's avatar kicici

namespace begin

Implemented using a #define trick I saw in pybind11.
If necessary we can a) change the namespace name, b) get rid of defines.
parent 301a3847
......@@ -29,6 +29,9 @@
#include <limits>
#include <regex> // C++11
#include "Common.h"
CUBISM_NAMESPACE_BEGIN
class Value
{
......@@ -489,3 +492,5 @@ public:
}
}
};
CUBISM_NAMESPACE_END
......@@ -35,9 +35,13 @@
#ifndef _CUBISM_BLOCK_H_
#define _CUBISM_BLOCK_H_
// DEPRECATED?
#include <cassert>
namespace cubism {
#include "Cubism.h"
CUBISM_NAMESPACE_BEGIN
template <typename T, int SX, int SY, int SZ>
class Block {
......@@ -73,6 +77,6 @@ public:
}
};
} // Namespace cubism.
CUBISM_NAMESPACE_END
#endif
......@@ -11,6 +11,8 @@
#include <cstdlib>
#include "MeshMap.h"
CUBISM_NAMESPACE_BEGIN
struct BlockInfo
{
long long blockID;
......@@ -151,3 +153,5 @@ struct BlockInfo
BlockInfo():blockID(-1), ptrBlock(NULL) {}
};
CUBISM_NAMESPACE_END
......@@ -9,12 +9,6 @@
//
#pragma once
#ifdef _FLOAT_PRECISION_
typedef float Real;
#else
typedef double Real;
#endif
#include "Matrix3D.h"
#include "Grid.h"
//#include "Concepts.h"
......@@ -29,6 +23,15 @@ typedef double Real;
#define memcpy2(a,b,c) memcpy((a),(b),(c))
#endif
CUBISM_NAMESPACE_BEGIN
#ifdef _FLOAT_PRECISION_
typedef float Real;
#else
typedef double Real;
#endif
/**
* Working copy of Block + Ghosts.
* Data of original block is copied (!) here. So when changing something in
......@@ -532,3 +535,5 @@ public:
this->m_state = BlockLab<BlockType, allocator, ElementTypeT>::eMRAGBlockLab_Prepared;
}
};
CUBISM_NAMESPACE_END
......@@ -10,6 +10,8 @@
#include "GridMPI.h"
CUBISM_NAMESPACE_BEGIN
template<typename MyBlockLab>
class BlockLabMPI : public MyBlockLab
{
......@@ -86,3 +88,5 @@ public:
MyBlockLab::release();
}
};
CUBISM_NAMESPACE_END
......@@ -23,6 +23,9 @@
#include <tbb/cache_aligned_allocator.h>
#include <tbb/task_scheduler_init.h>
CUBISM_NAMESPACE_BEGIN
namespace Environment
{
inline void setup(int threads=-1)
......@@ -309,3 +312,4 @@ int BlockProcessing_TBB<BlockType>::s_nBlocks = 0;
===============================================================================================================================
*/
CUBISM_NAMESPACE_END
......@@ -15,6 +15,8 @@
#include "BlockProcessing.h"
#include "SynchronizerMPI.h"
CUBISM_NAMESPACE_BEGIN
class BlockProcessingMPI
{
template<typename TGrid, typename Lab, typename Operator>
......@@ -89,3 +91,5 @@ public:
TBBWorker<Grid, Lab, Processing>::_process(vInfo, p, grid, SynchronizerMPI, t, affinitypart);
}
};
CUBISM_NAMESPACE_END
#ifndef CUBISM_H
#define CUBISM_H
#ifndef CUBISM_NAMESPACE_BEGIN
#define CUBISM_NAMESPACE_BEGIN namespace cubism {
#endif
#ifndef CUBISM_NAMESPACE_END
#define CUBISM_NAMESPACE_END } // namespace cubism
#endif
#endif
......@@ -13,6 +13,10 @@
#include <vector>
#include <cassert>
#include "Common.h"
CUBISM_NAMESPACE_BEGIN
struct Region {
int s[3], e[3];
......@@ -349,3 +353,5 @@ public:
}
};
CUBISM_NAMESPACE_END
......@@ -21,6 +21,8 @@
#include "BlockInfo.h"
#include "MeshMap.h"
CUBISM_NAMESPACE_BEGIN
//hello git
template <typename Block, template<typename X> class allocator=std::allocator>
class Grid
......@@ -239,3 +241,5 @@ std::ifstream& operator>> (std::ifstream& in, Grid<Block, allocator>& grid)
return in;
}
CUBISM_NAMESPACE_END
......@@ -16,6 +16,8 @@
#include "StencilInfo.h"
#include "SynchronizerMPI.h"
CUBISM_NAMESPACE_BEGIN
template < typename TGrid >
class GridMPI : public TGrid
{
......@@ -361,3 +363,5 @@ public:
high[2] = subdomain_high[2];
}
};
CUBISM_NAMESPACE_END
......@@ -15,6 +15,8 @@
#include "Grid.h"
#include "Indexers.h"
CUBISM_NAMESPACE_BEGIN
template <typename TGrid>
class GridMorton: public TGrid
{
......@@ -142,3 +144,5 @@ protected:
return cached_infos;
}
};
CUBISM_NAMESPACE_END
......@@ -28,6 +28,8 @@ typedef double hdf5Real;
#include "BlockInfo.h"
#include "MeshMap.h"
CUBISM_NAMESPACE_BEGIN
// The following requirements for the data TStreamer are required:
// TStreamer::NCHANNELS : Number of data elements (1=Scalar, 3=Vector, 9=Tensor)
// TStreamer::operate : Data access methods for read and write
......@@ -267,3 +269,5 @@ void ReadHDF5(TGrid &grid, const std::string fname, const std::string dpath=".")
#warning USE OF HDF WAS DISABLED AT COMPILE TIME
#endif
}
CUBISM_NAMESPACE_END
......@@ -32,6 +32,8 @@ typedef double hdf5Real;
#include "BlockInfo.h"
#include "MeshMap.h"
CUBISM_NAMESPACE_BEGIN
// The following requirements for the data TStreamer are required:
// TStreamer::NCHANNELS : Number of data elements (1=Scalar, 3=Vector, 9=Tensor)
// TStreamer::operate : Data access methods for read and write
......@@ -331,3 +333,5 @@ void ReadHDF5_MPI(TGrid &grid, const std::string fname, const std::string dpath=
#warning USE OF HDF WAS DISABLED AT COMPILE TIME
#endif
}
CUBISM_NAMESPACE_END
......@@ -29,6 +29,8 @@ typedef double hdf5Real;
#include "BlockInfo.h"
#include "MeshMap.h"
CUBISM_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
// helpers
namespace SliceTypes
......@@ -451,4 +453,6 @@ void DumpSliceHDF5(const TSlice& slice, const int stepID, const Real t, const st
#endif
}
CUBISM_NAMESPACE_END
#endif /* HDF5SLICEDUMPER_H_QI4Y9HO7 */
......@@ -11,6 +11,8 @@
#include <mpi.h>
#include "HDF5SliceDumper.h"
CUBISM_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
// helpers
namespace SliceTypesMPI
......@@ -268,4 +270,6 @@ void DumpSliceHDF5MPI(const TSlice& slice, const int stepID, const Real t, const
#endif
}
CUBISM_NAMESPACE_END
#endif /* HDF5SLICEDUMPERMPI_H_ZENQHJA6 */
......@@ -29,6 +29,8 @@ typedef double hdf5Real;
#include "BlockInfo.h"
#include "MeshMap.h"
CUBISM_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
// helpers
namespace SubdomainTypes
......@@ -498,4 +500,6 @@ void DumpSubdomainHDF5(const TSubdomain& subdomain, const int stepID, const Real
#endif
}
CUBISM_NAMESPACE_END
#endif /* HDF5SUBDOMAINDUMPER_H_3C2DKYV4 */
......@@ -30,6 +30,8 @@ typedef double hdf5Real;
#include "BlockInfo.h"
#include "MeshMap.h"
CUBISM_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
// helpers
namespace SubdomainTypesMPI
......@@ -374,4 +376,6 @@ void DumpSubdomainHDF5MPI(const TSubdomain& subdomain, const int stepID, const R
#endif
}
CUBISM_NAMESPACE_END
#endif /* HDF5SUBDOMAINDUMPERMPI_H_UAFPTNPL */
......@@ -13,6 +13,10 @@
#include <map>
#include <string>
#include "Common.h"
CUBISM_NAMESPACE_BEGIN
class Histogram
{
MPI_Comm m_comm;
......@@ -31,3 +35,5 @@ public:
void notify(std::string sKernel, float dt);
void consolidate();
};
CUBISM_NAMESPACE_END
......@@ -11,6 +11,10 @@
#include <cassert>
#include <cmath>
#include "Common.h"
CUBISM_NAMESPACE_BEGIN
class Indexer
{
protected:
......@@ -81,3 +85,5 @@ public:
}
}
};
CUBISM_NAMESPACE_END
......@@ -12,6 +12,10 @@
#include <cstring>
#include <zlib.h> // always needed
#include "Common.h"
CUBISM_NAMESPACE_BEGIN
extern "C"
{
#include "myfpzip.h"
......@@ -73,3 +77,5 @@ inline size_t ZZcompress(unsigned char *buf, unsigned len, int layout[4], unsign
#endif
return compressedbytes;
}
CUBISM_NAMESPACE_END
......@@ -12,6 +12,10 @@
#include <cstdlib>
#include <algorithm>
#include "Common.h"
CUBISM_NAMESPACE_BEGIN
template <class DataType, bool bPrimitiveType, template <typename T> class allocator>
class Matrix3D
{
......@@ -244,3 +248,5 @@ template <class DataType> inline void SwapBytes(unsigned char * pBuffer, int nBu
assert(i == nBufferSize); // se no son cazzi acidi
}
CUBISM_NAMESPACE_END
......@@ -11,6 +11,8 @@
#include <stdio.h>
#include "Matrix3D.h"
CUBISM_NAMESPACE_BEGIN
template <class DataType, bool bPrimitiveType, template <typename T> class allocator>
class Matrix4D
{
......@@ -190,3 +192,4 @@ template <class DataType, bool bPrimitiveType, template <typename T> class alloc
fread((void*) m_pData, sizeof(DataType), m_nElements, f);
}
CUBISM_NAMESPACE_END
......@@ -19,6 +19,8 @@
#include <random> // C++11
#include "ArgumentParser.h"
CUBISM_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
// Base class
///////////////////////////////////////////////////////////////////////////////
......@@ -834,4 +836,6 @@ private:
}
};
CUBISM_NAMESPACE_END
#endif /* MESHMAP_H_UAYWTJDH */
......@@ -9,6 +9,10 @@
#pragma once
#include <cstring>
#include "Common.h"
CUBISM_NAMESPACE_BEGIN
inline void pack(const Real * const srcbase, Real * const dst,
const unsigned int gptfloats,
......@@ -395,3 +399,5 @@ inline void unpack_subregion(const Real * const pack, Real * const dstbase,
dst[selected_components[c]] = src[c];
}
}
CUBISM_NAMESPACE_END
......@@ -14,6 +14,10 @@
#include <string>
#include <sstream>
#include "Common.h"
CUBISM_NAMESPACE_BEGIN
typedef struct _header
{
long offset;
......@@ -115,3 +119,5 @@ void PlainReadBin_MPI(MPI_Comm comm, TReal **buffer, long *bytes, const std::str
MPI_File_close(&file_id);
}
CUBISM_NAMESPACE_END
......@@ -24,6 +24,10 @@
//#include <tbb/tick_count.h>
//namespace tbb { class tick_count; }
#include "Common.h"
CUBISM_NAMESPACE_BEGIN
const bool bVerboseProfiling = false;
class ProfileAgent
......@@ -224,3 +228,5 @@ public:
friend class ProfileAgent;
};
CUBISM_NAMESPACE_END
......@@ -11,6 +11,9 @@
#include <vector>
#include <string>
#include "Common.h"
CUBISM_NAMESPACE_BEGIN
template<typename GridType, typename TStreamer>
class SerializerIO
......@@ -45,3 +48,4 @@ public:
}
};
CUBISM_NAMESPACE_END
......@@ -15,6 +15,8 @@
#include "SerializerIO.h"
CUBISM_NAMESPACE_BEGIN
template<typename GridType, typename TStreamer>
class SerializerIO_ImageVTK
{
......@@ -138,3 +140,5 @@ public:
writer->Write();
}
};
CUBISM_NAMESPACE_END
......@@ -13,6 +13,8 @@
#include "Types.h"
#include "Matrix4D.h"
CUBISM_NAMESPACE_BEGIN
template<typename GridType, typename TStreamer>
class SerializerIO_VP
{
......@@ -82,3 +84,4 @@ public:
}
};
CUBISM_NAMESPACE_END
......@@ -14,6 +14,10 @@
#include <iostream>
#include <cstdlib>
#include "Common.h"
CUBISM_NAMESPACE_BEGIN
#ifdef _FLOAT_PRECISION_
typedef float Real;
#else
......@@ -103,3 +107,5 @@ struct StencilInfo
return !(not0 || not1 || not2 || not3);
}
};
CUBISM_NAMESPACE_END
......@@ -21,6 +21,7 @@
#include "PUPkernelsMPI.h"
#include "DependencyCubeMPI.h"
CUBISM_NAMESPACE_BEGIN
class SynchronizerMPI
{
......@@ -1485,3 +1486,5 @@ class MyRange
}
}
};
CUBISM_NAMESPACE_END
......@@ -10,6 +10,10 @@
#pragma once
#include <sys/time.h>
#include "Common.h"
CUBISM_NAMESPACE_BEGIN
class Timer
{
struct timeval t_start, t_end;
......@@ -28,3 +32,5 @@ public:
return (t_end.tv_usec - t_start.tv_usec)*1e-6 + (t_end.tv_sec - t_start.tv_sec);
}
};
CUBISM_NAMESPACE_END
......@@ -13,15 +13,18 @@
#include <string>
#include <stdio.h>
#include <sstream>
#include "BlockInfo.h"
#include "LosslessCompression.h"
CUBISM_NAMESPACE_BEGIN
#ifdef _FLOAT_PRECISION_
typedef float Real;
#else
typedef double Real;
#endif
#include "BlockInfo.h"
#include "LosslessCompression.h"
typedef struct _header_serial
{
long size[8];
......@@ -219,3 +222,5 @@ void ReadZBin(TGrid &grid, const std::string f_name, const std::string read_path
status = fclose(file_id);
delete [] array_all;
}
CUBISM_NAMESPACE_END
......@@ -16,6 +16,11 @@
#include <cassert>
#include <sstream>
#include "BlockInfo.h"
#include "LosslessCompression.h"
CUBISM_NAMESPACE_BEGIN
#define MAX_MPI_PROCS (16*1024) // header: 0.25MB* 8
typedef struct _header
......@@ -31,9 +36,6 @@ typedef double Real;
#endif
#include "BlockInfo.h"
#include "LosslessCompression.h"
/*
inline size_t ZZcompress(unsigned char *buf, unsigned len, int layout[4], unsigned *max)
inline size_t ZZdecompress(unsigned char * inputbuf, size_t ninputbytes, int layout[4], unsigned char * outputbuf, const size_t maxsize);
......@@ -286,3 +288,5 @@ void ReadZBin_MPI(TGrid &grid, const std::string f_name, const std::string read_
MPI_File_close(&file_id);
delete [] array_all;
}
CUBISM_NAMESPACE_END
......@@ -15,6 +15,8 @@
using namespace std;
CUBISM_NAMESPACE_BEGIN
void Histogram::_setup()
{
int comm_rank;
......@@ -86,3 +88,5 @@ void Histogram::_print_statistcis(string sKernel, vector<float> & buf)
cout << sKernel << ": (Average, STD_DEV) ("<< avg << ", " << std_dev << ")" << endl;
}
CUBISM_NAMESPACE_END
......@@ -27,6 +27,8 @@ using MyReal = float;
#include <Cubism/BlockInfo.h>
using namespace cubism;
template <typename TReal, size_t _AOSmembers=1>
struct Block
{
......
......@@ -27,6 +27,7 @@
#include "Cubism/PlainBinDumper_MPI.h"
using namespace cubism;
using namespace std;
// dumpers
......
......@@ -14,6 +14,7 @@
#include "Cubism/StencilInfo.h"
#include "Cubism/Profiler.h"