Dhairya Malhotra 7 年之前
父節點
當前提交
522a793324
共有 5 個文件被更改,包括 37 次插入35 次删除
  1. 24 24
      include/sctl/comm.txx
  2. 1 1
      include/sctl/fft_wrapper.hpp
  3. 7 5
      include/sctl/matrix.txx
  4. 1 1
      include/sctl/mem_mgr.hpp
  5. 4 4
      include/sctl/mem_mgr.txx

+ 24 - 24
include/sctl/comm.txx

@@ -95,8 +95,8 @@ template <class SType> void* Comm::Isend(ConstIterator<SType> sbuf, Long scount,
   Vector<MPI_Request>& request = *NewReq();
   request.ReInit(1);
 
-  sbuf[0];
-  sbuf[scount - 1];
+  SCTL_UNUSED(sbuf[0]         );
+  SCTL_UNUSED(sbuf[scount - 1]);
 #ifndef NDEBUG
   MPI_Issend(&sbuf[0], scount, CommDatatype<SType>::value(), dest, tag, mpi_comm_, &request[0]);
 #else
@@ -120,8 +120,8 @@ template <class RType> void* Comm::Irecv(Iterator<RType> rbuf, Long rcount, Inte
   Vector<MPI_Request>& request = *NewReq();
   request.ReInit(1);
 
-  rbuf[0];
-  rbuf[rcount - 1];
+  SCTL_UNUSED(rbuf[0]         );
+  SCTL_UNUSED(rbuf[rcount - 1]);
   MPI_Irecv(&rbuf[0], rcount, CommDatatype<RType>::value(), source, tag, mpi_comm_, &request[0]);
   return &request;
 #else
@@ -149,12 +149,12 @@ template <class SType, class RType> void Comm::Allgather(ConstIterator<SType> sb
   static_assert(std::is_trivially_copyable<RType>::value, "Data is not trivially copyable!");
 #ifdef SCTL_HAVE_MPI
   if (scount) {
-    sbuf[0];
-    sbuf[scount - 1];
+    SCTL_UNUSED(sbuf[0]         );
+    SCTL_UNUSED(sbuf[scount - 1]);
   }
   if (rcount) {
-    rbuf[0];
-    rbuf[rcount * Size() - 1];
+    SCTL_UNUSED(rbuf[0]                  );
+    SCTL_UNUSED(rbuf[rcount * Size() - 1]);
   }
   MPI_Allgather((scount ? &sbuf[0] : nullptr), scount, CommDatatype<SType>::value(), (rcount ? &rbuf[0] : nullptr), rcount, CommDatatype<RType>::value(), mpi_comm_);
 #else
@@ -175,12 +175,12 @@ template <class SType, class RType> void Comm::Allgatherv(ConstIterator<SType> s
     rcount_sum += rcounts[i];
   }
   if (scount) {
-    sbuf[0];
-    sbuf[scount - 1];
+    SCTL_UNUSED(sbuf[0]         );
+    SCTL_UNUSED(sbuf[scount - 1]);
   }
   if (rcount_sum) {
-    rbuf[0];
-    rbuf[rcount_sum - 1];
+    SCTL_UNUSED(rbuf[0]             );
+    SCTL_UNUSED(rbuf[rcount_sum - 1]);
   }
   MPI_Allgatherv((scount ? &sbuf[0] : nullptr), scount, CommDatatype<SType>::value(), (rcount_sum ? &rbuf[0] : nullptr), &rcounts_.begin()[0], &rdispls_.begin()[0], CommDatatype<RType>::value(), mpi_comm_);
 #else
@@ -193,12 +193,12 @@ template <class SType, class RType> void Comm::Alltoall(ConstIterator<SType> sbu
   static_assert(std::is_trivially_copyable<RType>::value, "Data is not trivially copyable!");
 #ifdef SCTL_HAVE_MPI
   if (scount) {
-    sbuf[0];
-    sbuf[scount * Size() - 1];
+    SCTL_UNUSED(sbuf[0]                  );
+    SCTL_UNUSED(sbuf[scount * Size() - 1]);
   }
   if (rcount) {
-    rbuf[0];
-    rbuf[rcount * Size() - 1];
+    SCTL_UNUSED(rbuf[0]                  );
+    SCTL_UNUSED(rbuf[rcount * Size() - 1]);
   }
   MPI_Alltoall((scount ? &sbuf[0] : nullptr), scount, CommDatatype<SType>::value(), (rcount ? &rbuf[0] : nullptr), rcount, CommDatatype<RType>::value(), mpi_comm_);
 #else
@@ -308,10 +308,10 @@ template <class Type> void Comm::Allreduce(ConstIterator<Type> sbuf, Iterator<Ty
       mpi_op = MPI_OP_NULL;
       break;
   }
-  sbuf[0];
-  sbuf[count - 1];
-  rbuf[0];
-  rbuf[count - 1];
+  SCTL_UNUSED(sbuf[0]        );
+  SCTL_UNUSED(sbuf[count - 1]);
+  SCTL_UNUSED(rbuf[0]        );
+  SCTL_UNUSED(rbuf[count - 1]);
   MPI_Allreduce(&sbuf[0], &rbuf[0], count, CommDatatype<Type>::value(), mpi_op, mpi_comm_);
 #else
   memcopy((Iterator<char>)rbuf, (ConstIterator<char>)sbuf, count * sizeof(Type));
@@ -337,10 +337,10 @@ template <class Type> void Comm::Scan(ConstIterator<Type> sbuf, Iterator<Type> r
       mpi_op = MPI_OP_NULL;
       break;
   }
-  sbuf[0];
-  sbuf[count - 1];
-  rbuf[0];
-  rbuf[count - 1];
+  SCTL_UNUSED(sbuf[0]        );
+  SCTL_UNUSED(sbuf[count - 1]);
+  SCTL_UNUSED(rbuf[0]        );
+  SCTL_UNUSED(rbuf[count - 1]);
   MPI_Scan(&sbuf[0], &rbuf[0], count, CommDatatype<Type>::value(), mpi_op, mpi_comm_);
 #else
   memcopy((Iterator<char>)rbuf, (ConstIterator<char>)sbuf, count * sizeof(Type));

+ 1 - 1
include/sctl/fft_wrapper.hpp

@@ -303,7 +303,7 @@ template <> class FFT<double> : public FFT_Generic<double, FFT<double>> {
     Long rank = dim_vec.Dim();
     this->fft_type = fft_type_;
     this->howmany = howmany_;
-    Long N0, N1;
+    Long N0 = 0, N1 = 0;
     { // Set N0, N1
       Long N = howmany;
       for (auto ni : dim_vec) N *= ni;

+ 7 - 5
include/sctl/matrix.txx

@@ -118,18 +118,20 @@ template <class ValueType> void Matrix<ValueType>::Read(const char* fname) {
   }
   StaticArray<uint64_t, 2> dim_;
   Long readlen = fread(&dim_[0], sizeof(uint64_t), 2, f1);
-  assert(readlen == 2);
+  SCTL_ASSERT(readlen == 2);
 
-  if (Dim(0)!=dim_[0] || Dim(1)!=dim_[1]) ReInit(dim_[0], dim_[1]);
-  if (dim_[0] * dim_[1]) readlen = fread(&data_ptr[0], sizeof(ValueType), dim_[0] * dim_[1], f1);
-  assert(readlen == dim_[0] * dim_[1]);
+  if (Dim(0) != (Long)dim_[0] || Dim(1) != (Long)dim_[1]) ReInit(dim_[0], dim_[1]);
+  if (dim_[0] && dim_[1]) {
+    readlen = fread(&data_ptr[0], sizeof(ValueType), dim_[0] * dim_[1], f1);
+    SCTL_ASSERT(readlen == (Long)(dim_[0] * dim_[1]));
+  }
   fclose(f1);
 }
 
 template <class ValueType> Long Matrix<ValueType>::Dim(Long i) const { return dim[i]; }
 
 template <class ValueType> void Matrix<ValueType>::SetZero() {
-  if (dim[0] * dim[1]) memset(data_ptr, 0, dim[0] * dim[1]);
+  if (dim[0] && dim[1]) memset(data_ptr, 0, dim[0] * dim[1]);
 }
 
 template <class ValueType> Iterator<ValueType> Matrix<ValueType>::begin() { return data_ptr; }

+ 1 - 1
include/sctl/mem_mgr.hpp

@@ -249,7 +249,7 @@ template <class ValueType, Long DIM> class StaticArray : public Iterator<ValueTy
   StaticArray(std::initializer_list<ValueType> arr_) : StaticArray() {
     // static_assert(arr_.size() <= DIM, "too many initializer values"); // allowed in C++14
     SCTL_ASSERT_MSG(arr_.size() <= DIM, "too many initializer values");
-    for (Long i = 0; i < arr_.size(); i++) arr[i] = arr_.begin()[i];
+    for (Long i = 0; i < (Long)arr_.size(); i++) arr[i] = arr_.begin()[i];
   }
 
  private:

+ 4 - 4
include/sctl/mem_mgr.txx

@@ -532,8 +532,8 @@ template <class ValueType> inline void aligned_delete(Iterator<ValueType> A, con
 template <class ValueType> inline Iterator<ValueType> memcopy(Iterator<ValueType> destination, ConstIterator<ValueType> source, Long num) {
   if (destination != source && num) {
 #ifdef SCTL_MEMDEBUG
-    destination[num - 1];
-    source[num - 1];
+    SCTL_UNUSED(destination[num - 1]);
+    SCTL_UNUSED(source[num - 1]     );
 #endif
     if (std::is_trivially_copyable<ValueType>::value) {
       memcpy(&destination[0], &source[0], num * sizeof(ValueType));
@@ -547,8 +547,8 @@ template <class ValueType> inline Iterator<ValueType> memcopy(Iterator<ValueType
 template <class ValueType> inline Iterator<ValueType> memset(Iterator<ValueType> ptr, int value, Long num) {
   if (num) {
 #ifdef SCTL_MEMDEBUG
-    ptr[0];
-    ptr[num - 1];
+    SCTL_UNUSED(ptr[0]      );
+    SCTL_UNUSED(ptr[num - 1]);
 #endif
     ::memset(&ptr[0], value, num * sizeof(ValueType));
   }