Commit 063c0ec8 authored by fabianw's avatar fabianw

fix compiler warnings

parent f9e21938
......@@ -106,7 +106,6 @@ protected:
TBlock& operator()( int ix, int iy = 0, int iz = 0) const
{
const int N = this->N;
const int NX = this->NX;
const int NY = this->NY;
const int NZ = this->NZ;
......@@ -129,7 +128,7 @@ protected:
assert(iflat >= 0 && iflat < f2m.size());
const unsigned int idx = f2m[iflat];
assert(idx >= 0 && idx < N);
assert(idx >= 0 && idx < this->N);
return *(this->_linaccess(idx));
}
......
......@@ -232,6 +232,7 @@ namespace SubdomainTypes
}
Subdomain(const Subdomain& c) = default;
virtual ~Subdomain() = default;
inline int id() const { return m_id; }
inline const int (&bbox_start() const)[3] { return m_bbox_start; }
......
......@@ -23,7 +23,6 @@ class Histogram
std::map<std::string,std::vector<float> > mk2t;
bool isroot;
bool bInitialized;
int reportID;
void _print2file(std::string sKernel, std::vector<float> & buf);
void _print_statistcis(std::string sKernel, std::vector<float> & buf);
......
......@@ -19,22 +19,22 @@ class Indexer
{
protected:
const unsigned int sizeX, sizeY, sizeZ, sizeTotal;
public:
Indexer(const unsigned int sizeX, const unsigned int sizeY, const unsigned int sizeZ):
sizeX(sizeX), sizeY(sizeY), sizeZ(sizeZ), sizeTotal(sizeX*sizeY*sizeZ)
public:
Indexer(const unsigned int sizeX_, const unsigned int sizeY_, const unsigned int sizeZ_):
sizeX(sizeX_), sizeY(sizeY_), sizeZ(sizeZ_), sizeTotal(sizeX_*sizeY_*sizeZ_)
{
}
virtual unsigned int encode(unsigned int ix, unsigned int iy, unsigned int iz) const
{
const unsigned int retval = ix + sizeX*(iy + iz*sizeY);
assert(retval < sizeTotal && retval>=0);
return retval;
return retval;
}
virtual void decode(unsigned int code, unsigned int& ix, unsigned int& iy, unsigned int& iz) const
{
ix = code % sizeX;
......@@ -47,33 +47,33 @@ class IndexerMorton : public Indexer
{
unsigned int depth;
public:
IndexerMorton(const unsigned int sizeX, const unsigned int sizeY, const unsigned int sizeZ):
Indexer(sizeX, sizeY, sizeZ)
IndexerMorton(const unsigned int sizeX_, const unsigned int sizeY_, const unsigned int sizeZ_):
Indexer(sizeX_, sizeY_, sizeZ_)
{
depth = (unsigned int) fmin(10., ceil(log2((double)fmax(sizeX,fmax(sizeY,sizeZ)))));
}
unsigned int encode(unsigned int ix, unsigned int iy, unsigned int iz) const
{
unsigned int idx=0;
for(unsigned int counter=0;counter<depth;++counter)
{
const unsigned int bitmask = 1 << counter;
const unsigned int idx0 = ix&bitmask;
const unsigned int idx1 = iy&bitmask;
const unsigned int idx2 = iz&bitmask;
idx |= ((idx0<<2*counter) | (idx1<<(2*counter+1)) | (idx2<<(2*counter+2)));
}
return idx;
return idx;
}
void decode(unsigned int code, unsigned int& ix, unsigned int& iy, unsigned int& iz) const
{
ix=iy=iz=0;
for(unsigned int counter=0;counter<depth;++counter)
{
const unsigned int bitmask_x = 1 << (counter*3+0);
......
......@@ -14,6 +14,8 @@
#include "Common.h"
#define DBG 0
CUBISM_NAMESPACE_BEGIN
extern "C"
......@@ -48,7 +50,7 @@ inline size_t
ZZcompress(unsigned char *buf, size_t len, int layout[4], size_t *max)
{
#if 1
int zbufsize = 0;
size_t zbufsize = 0;
char *zbuf = NULL;
zbufsize = len + 4096;
zbuf = (char *)malloc(zbufsize);
......
......@@ -13,6 +13,7 @@
#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <mpi.h>
#include "Common.h"
......@@ -110,7 +111,8 @@ void PlainReadBin_MPI(MPI_Comm comm, TReal **buffer, long *bytes, const std::str
#if DBG
printf("Reading %ld bytes of binary data\n", lbytes);
#endif
unsigned char *tmp = (unsigned char *) malloc(lbytes);
unsigned long *tmp = nullptr;
posix_memalign((void**)&tmp, 16, lbytes);
long base = MAX_MPI_PROCS*sizeof(tag); // Header
MPI_File_read_at(file_id, base + offset, (char *)tmp, lbytes, MPI_CHAR, &status);
......@@ -119,6 +121,7 @@ void PlainReadBin_MPI(MPI_Comm comm, TReal **buffer, long *bytes, const std::str
*bytes = lbytes;
MPI_File_close(&file_id);
free(tmp);
}
CUBISM_NAMESPACE_END
......@@ -17,6 +17,8 @@
#include "BlockInfo.h"
#include "LosslessCompression.h"
#define DBG 0
CUBISM_NAMESPACE_BEGIN
typedef struct _header_serial {
......@@ -43,7 +45,6 @@ void DumpZBin(const TGrid &grid,
filename << dump_path << "/" << f_name;
FILE *file_id;
int status;
static const int NCHANNELS = TStreamer::NCHANNELS;
const int NX = grid.getBlocksPerDimension(0) * B::sizeX;
......@@ -119,13 +120,13 @@ void DumpZBin(const TGrid &grid,
compressed_bytes);
tag.size[ichannel] = compressed_bytes;
size_t wb_data = fwrite(array_all, 1, compressed_bytes, file_id);
fwrite(array_all, 1, compressed_bytes, file_id);
}
fseek(file_id, 0, SEEK_SET);
size_t wb_header = fwrite(&tag.size[0], 1, sizeof(tag), file_id);
fwrite(&tag.size[0], 1, sizeof(tag), file_id);
status = fclose(file_id);
fclose(file_id);
delete[] array_all;
}
......@@ -142,7 +143,6 @@ void ReadZBin(TGrid &grid,
std::ostringstream filename;
filename << read_path << "/" << f_name;
int status;
FILE *file_id;
const int NX = grid.getBlocksPerDimension(0) * B::sizeX;
......@@ -168,7 +168,7 @@ void ReadZBin(TGrid &grid,
size_t local_bytes = local_count * sizeof(Real);
header_serial tag;
size_t rb_header = fread(&tag.size[0], 1, sizeof(tag), file_id);
fread(&tag.size[0], 1, sizeof(tag), file_id);
#if DBG
printf("HEADER(%d):\n", rank);
......@@ -191,10 +191,12 @@ void ReadZBin(TGrid &grid,
#endif
unsigned char *tmp = (unsigned char *)malloc(compressed_bytes + 4096);
size_t rb_data = fread(tmp, 1, compressed_bytes, file_id);
fread(tmp, 1, compressed_bytes, file_id);
int layout[4] = {NX, NY, NZ, 1};
#if DBG
size_t decompressed_bytes =
#endif
ZZdecompress<typename TGrid::Real>(tmp,
compressed_bytes,
layout,
......@@ -227,7 +229,7 @@ void ReadZBin(TGrid &grid,
}
} /* ichannel */
status = fclose(file_id);
fclose(file_id);
delete [] array_all;
}
......
......@@ -19,6 +19,8 @@
#include "BlockInfo.h"
#include "LosslessCompression.h"
#define DBG 0
CUBISM_NAMESPACE_BEGIN
#define MAX_MPI_PROCS (16 * 1024) // header: 0.25MB* 8
......@@ -246,13 +248,13 @@ void ReadZBin_MPI(TGrid &grid,
// size_t local_count = NX * NY * NZ * NCHANNELS;
size_t local_count = NX * NY * NZ * 1;
size_t local_bytes = local_count * sizeof(Real);
long offset;
header tag;
MPI_File_read_at(
file_id, rank * sizeof(tag), &tag, 2 * 8, MPI_LONG, &status);
#if DBG
long offset;
printf("HEADER(%d):\n", rank);
for (int i = 0; i < NCHANNELS; i++) {
printf("channel %d: %ld %ld\n", i, tag.offset[i], tag.size[i]);
......@@ -289,7 +291,9 @@ void ReadZBin_MPI(TGrid &grid,
// int layout[4] = {NCHANNELS, NX, NY, NZ};
int layout[4] = {NX, NY, NZ, 1};
#if DBG
size_t decompressed_bytes =
#endif
ZZdecompress<typename TGrid::Real>(tmp,
compressed_bytes,
layout,
......
......@@ -67,7 +67,7 @@ void Histogram::_print2file(string sKernel, vector<float> & buf)
sprintf(f_name_ascii, "hist_%s", sKernel.c_str());
FILE * pFile_ascii = fopen(f_name_ascii, "a");
for(int i=0; i<buf.size(); ++i)
for(size_t i=0; i<buf.size(); ++i)
fprintf(pFile_ascii, "%e\n", buf[i]);
fclose (pFile_ascii);
}
......
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