Dhairya Malhotra 7 år sedan
förälder
incheckning
e610cf1f1f

+ 1 - 0
include/sctl/comm.txx

@@ -40,6 +40,7 @@ inline Comm& Comm::operator=(const Comm& c) {
 #ifdef SCTL_HAVE_MPI
   Init(c.mpi_comm_);
 #endif
+  return *this;
 }
 
 inline Comm::~Comm() {

+ 12 - 12
include/sctl/fft_wrapper.hpp

@@ -296,10 +296,10 @@ template <> class FFT<double> : public FFT_Generic<double, FFT<double>> {
 
  public:
 
-  ~FFT() { if (this->Dim(0) * this->Dim(1)) fftw_destroy_plan(plan); }
+  ~FFT() { if (this->Dim(0) && this->Dim(1)) fftw_destroy_plan(plan); }
 
   void Setup(FFT_Type fft_type_, Long howmany_, const Vector<Long>& dim_vec) {
-    if (Dim(0) * Dim(1)) fftw_destroy_plan(plan);
+    if (Dim(0) && Dim(1)) fftw_destroy_plan(plan);
     Long rank = dim_vec.Dim();
     this->fft_type = fft_type_;
     this->howmany = howmany_;
@@ -323,7 +323,7 @@ template <> class FFT<double> : public FFT_Generic<double, FFT<double>> {
       this->dim[0] = N0;
       this->dim[1] = N1;
     }
-    if (!N0 * N1) return;
+    if (!N0 || !N1) return;
 
     in .ReInit(N0);
     out.ReInit(N1);
@@ -344,7 +344,7 @@ template <> class FFT<double> : public FFT_Generic<double, FFT<double>> {
   void Execute(const Vector<ValueType>& in, Vector<ValueType>& out) const {
     Long N0 = this->Dim(0);
     Long N1 = this->Dim(1);
-    if (!N0 * N1) return;
+    if (!N0 || !N1) return;
     SCTL_ASSERT_MSG(in.Dim() == N0, "FFT: Wrong input size.");
     if (out.Dim() != N1) out.ReInit(N1);
 
@@ -379,10 +379,10 @@ template <> class FFT<float> : public FFT_Generic<float, FFT<float>> {
 
  public:
 
-  ~FFT() { if (this->Dim(0) * this->Dim(1)) fftwf_destroy_plan(plan); }
+  ~FFT() { if (this->Dim(0) && this->Dim(1)) fftwf_destroy_plan(plan); }
 
   void Setup(FFT_Type fft_type_, Long howmany_, const Vector<Long>& dim_vec) {
-    if (Dim(0) * Dim(1)) fftwf_destroy_plan(plan);
+    if (Dim(0) && Dim(1)) fftwf_destroy_plan(plan);
     Long rank = dim_vec.Dim();
     this->fft_type = fft_type_;
     this->howmany = howmany_;
@@ -406,7 +406,7 @@ template <> class FFT<float> : public FFT_Generic<float, FFT<float>> {
       this->dim[0] = N0;
       this->dim[1] = N1;
     }
-    if (!N0 * N1) return;
+    if (!N0 || !N1) return;
 
     in .ReInit(N0);
     out.ReInit(N1);
@@ -427,7 +427,7 @@ template <> class FFT<float> : public FFT_Generic<float, FFT<float>> {
   void Execute(const Vector<ValueType>& in, Vector<ValueType>& out) const {
     Long N0 = this->Dim(0);
     Long N1 = this->Dim(1);
-    if (!N0 * N1) return;
+    if (!N0 || !N1) return;
     SCTL_ASSERT_MSG(in.Dim() == N0, "FFT: Wrong input size.");
     if (out.Dim() != N1) out.ReInit(N1);
 
@@ -462,10 +462,10 @@ template <> class FFT<long double> : public FFT_Generic<long double, FFT<long do
 
  public:
 
-  ~FFT() { if (this->Dim(0) * this->Dim(1)) fftwl_destroy_plan(plan); }
+  ~FFT() { if (this->Dim(0) && this->Dim(1)) fftwl_destroy_plan(plan); }
 
   void Setup(FFT_Type fft_type_, Long howmany_, const Vector<Long>& dim_vec) {
-    if (Dim(0) * Dim(1)) fftwl_destroy_plan(plan);
+    if (Dim(0) && Dim(1)) fftwl_destroy_plan(plan);
     Long rank = dim_vec.Dim();
     this->fft_type = fft_type_;
     this->howmany = howmany_;
@@ -489,7 +489,7 @@ template <> class FFT<long double> : public FFT_Generic<long double, FFT<long do
       this->dim[0] = N0;
       this->dim[1] = N1;
     }
-    if (!N0 * N1) return;
+    if (!N0 || !N1) return;
 
     in .ReInit(N0);
     out.ReInit(N1);
@@ -510,7 +510,7 @@ template <> class FFT<long double> : public FFT_Generic<long double, FFT<long do
   void Execute(const Vector<ValueType>& in, Vector<ValueType>& out) const {
     Long N0 = this->Dim(0);
     Long N1 = this->Dim(1);
-    if (!N0 * N1) return;
+    if (!N0 || !N1) return;
     SCTL_ASSERT_MSG(in.Dim() == N0, "FFT: Wrong input size.");
     if (out.Dim() != N1) out.ReInit(N1);
 

+ 8 - 8
include/sctl/mem_mgr.txx

@@ -158,7 +158,7 @@ inline void MemoryManager::CheckMemHead(const MemHead& mem_head) {  // Verify he
 #ifdef SCTL_MEMDEBUG
   Long check_sum = 0;
   const unsigned char* base_ = (const unsigned char*)&mem_head;
-  for (Integer i = 0; i < sizeof(MemHead); i++) {
+  for (Integer i = 0; i < (Integer)sizeof(MemHead); i++) {
     check_sum += base_[i];
   }
   check_sum -= mem_head.check_sum;
@@ -225,7 +225,7 @@ inline Iterator<char> MemoryManager::malloc(const Long n_elem, const Long type_s
     }
     {  // set p[*] to init_mem_val
 #pragma omp parallel for
-      for (Long i = 0; i < size + 2 + alignment + end_padding; i++) p[i] = init_mem_val;
+      for (Long i = 0; i < (Long)(size + 2 + alignment + end_padding); i++) p[i] = init_mem_val;
     }
 #endif
     {  // base <-- align(p)
@@ -246,7 +246,7 @@ inline Iterator<char> MemoryManager::malloc(const Long n_elem, const Long type_s
   MemHead& mem_head = *(MemHead*)base;
   {  // Set mem_head
 #ifdef SCTL_MEMDEBUG
-    for (Integer i = 0; i < sizeof(MemHead); i++) base[i] = init_mem_val;
+    for (Integer i = 0; i < (Integer)sizeof(MemHead); i++) base[i] = init_mem_val;
 #endif
     mem_head.n_indx = n_indx;
     mem_head.n_elem = n_elem;
@@ -259,7 +259,7 @@ inline Iterator<char> MemoryManager::malloc(const Long n_elem, const Long type_s
     Long check_sum = 0;
     unsigned char* base_ = (unsigned char*)base;
     mem_head.check_sum = 0;
-    for (Integer i = 0; i < sizeof(MemHead); i++) check_sum += base_[i];
+    for (Integer i = 0; i < (Integer)sizeof(MemHead); i++) check_sum += base_[i];
     check_sum = check_sum & ((1UL << (8 * sizeof(mem_head.check_sum))) - 1);
     mem_head.check_sum = check_sum;
 #endif
@@ -289,7 +289,7 @@ inline void MemoryManager::free(Iterator<char> p) const {
     Long size = mem_head.n_elem * mem_head.type_size;
 #pragma omp parallel for
     for (Long i = 0; i < size; i++) p[i] = init_mem_val;
-    for (Integer i = 0; i < sizeof(MemHead); i++) base[i] = init_mem_val;
+    for (Integer i = 0; i < (Integer)sizeof(MemHead); i++) base[i] = init_mem_val;
 #endif
   }
 
@@ -308,7 +308,7 @@ inline void MemoryManager::free(Iterator<char> p) const {
       size = (uintptr_t)(size + alignment) & ~(uintptr_t)alignment;
       Long end_padding = 8;  // to check for out-of-bound writes
 #pragma omp parallel for
-      for (Long i = 0; i < size + 2 + alignment + end_padding; i++) {
+      for (Long i = 0; i < (Long)(size + 2 + alignment + end_padding); i++) {
         SCTL_ASSERT_MSG(p_[i] == init_mem_val, "memory corruption detected.");
       }
     }
@@ -320,7 +320,7 @@ inline void MemoryManager::free(Iterator<char> p) const {
 #endif
     ::free(p_);
   } else {
-    assert(n_indx <= node_buff.size());
+    assert(n_indx <= (Long)node_buff.size());
     omp_set_lock(&omp_lock);
     MemNode& n = node_buff[n_indx - 1];
     assert(!n.free && n.size > 0 && n.mem_ptr == base);
@@ -454,7 +454,7 @@ inline Long MemoryManager::new_node() const {
 
 inline void MemoryManager::delete_node(Long indx) const {
   assert(indx);
-  assert(indx <= node_buff.size());
+  assert(indx <= (Long)node_buff.size());
   MemNode& n = node_buff[indx - 1];
   n.free = false;
   n.size = 0;

+ 2 - 2
include/sctl/profile.txx

@@ -40,7 +40,7 @@ inline void Profile::Tic(const char* name_, const Comm* comm_, bool sync_, Integ
   ProfileData& prof = ProfData();
   if (!prof.enable_state) return;
   // sync_=true;
-  if (verbose <= SCTL_PROFILE && prof.verb_level.size() == prof.enable_depth) {
+  if (verbose <= SCTL_PROFILE && (Integer)prof.verb_level.size() == prof.enable_depth) {
     if (comm_ != nullptr && sync_) comm_->Barrier();
 #ifdef SCTL_VERBOSE
     Integer rank = 0;
@@ -72,7 +72,7 @@ inline void Profile::Toc() {
   ProfileData& prof = ProfData();
   if (!prof.enable_state) return;
   SCTL_ASSERT_MSG(!prof.verb_level.empty(), "Unbalanced extra Toc()");
-  if (prof.verb_level.top() <= SCTL_PROFILE && prof.verb_level.size() == prof.enable_depth) {
+  if (prof.verb_level.top() <= SCTL_PROFILE && (Integer)prof.verb_level.size() == prof.enable_depth) {
     SCTL_ASSERT_MSG(!prof.name.empty() && !prof.comm.empty() && !prof.sync.empty() && !prof.max_mem.empty(), "Unbalanced extra Toc()");
     std::string name_ = prof.name.top();
     const Comm* comm_ = prof.comm.top();

+ 5 - 5
include/sctl/stacktrace.h

@@ -37,9 +37,9 @@ inline void print_stacktrace(FILE* out = stderr, int skip = 1) {
     // Get command
     char cmd[10240];
 #ifdef __APPLE__
-    sprintf(cmd, "atos -o %s %016p 2> /dev/null", fname, addrlist[i]); // on mac
+    sprintf(cmd, "atos -o %s %p 2> /dev/null", fname, addrlist[i]); // on mac
 #elif __linux__
-    sprintf(cmd, "addr2line -f -C -i -e  %s  %016p 2> /dev/null", fname, addrlist[i]);
+    sprintf(cmd, "addr2line -f -C -i -e  %s  %p 2> /dev/null", fname, addrlist[i]);
 #endif
 
     // Execute command
@@ -49,10 +49,10 @@ inline void print_stacktrace(FILE* out = stderr, int skip = 1) {
     char buffer1[10240];
     fgets(buffer0, sizeof(buffer0) - 1, pipe);
     fgets(buffer1, sizeof(buffer1) - 1, pipe);
-    for (int j = 0; j < sizeof(buffer0) - 1; j++) {
+    for (int j = 0; j < (int)sizeof(buffer0) - 1; j++) {
       if (buffer0[j] == '\n') buffer0[j] = ' ';
     }
-    for (int j = 0; j < sizeof(buffer1) - 1; j++) {
+    for (int j = 0; j < (int)sizeof(buffer1) - 1; j++) {
       if (buffer1[j] == '\n') buffer1[j] = ' ';
     }
     pclose(pipe);
@@ -61,7 +61,7 @@ inline void print_stacktrace(FILE* out = stderr, int skip = 1) {
     if (buffer0[0] != '?' && buffer0[0] != '\0') {
       fprintf(out, "[%d] %s: %s\n", i - skip, buffer1, buffer0);
     } else {
-      fprintf(out, "[%d] %016p: %s\n", i - skip, addrlist[i], symbollist[i]);
+      fprintf(out, "[%d] %p: %s\n", i - skip, addrlist[i], symbollist[i]);
     }
   }
   fprintf(stderr, "\n");