From d2d773f394e7061c164d41ebbd6b0ee1641ba74d Mon Sep 17 00:00:00 2001
From: bramas <berenger.bramas@inria.fr>
Date: Tue, 9 Dec 2014 16:37:58 +0100
Subject: [PATCH] Remove some warnings and add the patch for the omp to starpu
 auto version

---
 CMakeLists.txt                               |  8 ++++++--
 Examples/compareAllPoissonKernels.cpp        |  2 +-
 Src/Utils/FSmartPointer.hpp                  | 13 +++++++++++--
 Src/Utils/FSse.hpp                           |  8 ++++++++
 Tests/Utils/testFmmAlgorithmProcRotation.cpp |  3 ++-
 Tests/noDist/testP2PAvx.cpp                  |  1 -
 Tests/noDist/testSphericalBlasBlockProc.cpp  |  1 -
 UTests/utestMpiQs.cpp                        | 12 ++++++------
 Utils/noDist/removeMoment.cpp                |  6 +++---
 9 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index edeb140f0..cc4342bfb 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -111,8 +111,12 @@ else()
     # NOT      INTEL
     if(NOT ${ScalFMM_USE_MPI})
         SET(ScaLFMM_CXX_FLAGS  "${ScaLFMM_CXX_FLAGS}   -Wzero-as-null-pointer-constant")
-	else()
-		SET(ScaLFMM_CXX_FLAGS  "${ScaLFMM_CXX_FLAGS}   -Wno-literal-suffix")
+    else()
+        include(CheckCCompilerFlag)
+        check_c_compiler_flag(-Wno-literal-suffix HAS_NO_LITERAL_SUFFIX_FLAG)
+        if(HAS_NO_LITERAL_SUFFIX_FLAG)
+            SET(ScaLFMM_CXX_FLAGS  "${ScaLFMM_CXX_FLAGS}   -Wno-literal-suffix")
+        endif()
     endif()
     SET(AVX_FLAGS "-mtune=native -march=native")
 IF (APPLE)
diff --git a/Examples/compareAllPoissonKernels.cpp b/Examples/compareAllPoissonKernels.cpp
index c74ee6814..c1fe9d9aa 100644
--- a/Examples/compareAllPoissonKernels.cpp
+++ b/Examples/compareAllPoissonKernels.cpp
@@ -118,7 +118,7 @@ int main(int argc, char* argv[])
 #ifdef _OPENMP
 	omp_set_num_threads(NbThreads);
 #else
-	std::cout << "\n>> Sequential version.\n" << std::
+    std::cout << "\n>> Sequential version.\n" << std::endl;
 #endif
 
 	std::cout <<	 "Parameters  "<< std::endl
diff --git a/Src/Utils/FSmartPointer.hpp b/Src/Utils/FSmartPointer.hpp
index e6c972b1a..b77985080 100755
--- a/Src/Utils/FSmartPointer.hpp
+++ b/Src/Utils/FSmartPointer.hpp
@@ -22,6 +22,16 @@ enum FSmartPointerType{
     FSmartPointerMemory
 };
 
+template <FSmartPointerType MemoryType, class ClassType>
+inline typename std::enable_if<(MemoryType == FSmartArrayMemory), void>::type FSmartDeletePointer(ClassType* ptr){
+    delete ptr;
+}
+
+template <FSmartPointerType MemoryType, class ClassType>
+inline typename std::enable_if<(MemoryType == FSmartPointerMemory), void>::type FSmartDeletePointer(ClassType* ptr){
+    delete[] ptr;
+}
+
 /** This class is a basic smart pointer class
   * Use as FSmartPointer<int> array = new int[5];
   * FSmartPointer<int, PointerMemory> pt = new int;
@@ -87,8 +97,7 @@ public:
         if(counter){
             (*counter) -= 1;
             if( (*counter) == 0 ){
-                if(MemoryType == FSmartArrayMemory) delete[] pointer;
-                else if(MemoryType == FSmartPointerMemory) delete pointer;
+                FSmartDeletePointer<MemoryType>(pointer);
                 delete counter;
             }
             pointer = nullptr;
diff --git a/Src/Utils/FSse.hpp b/Src/Utils/FSse.hpp
index 0aeb20401..f3bb4236b 100644
--- a/Src/Utils/FSse.hpp
+++ b/Src/Utils/FSse.hpp
@@ -26,6 +26,14 @@
 #include <smmintrin.h> // SSE4
 #endif
 
+
+#ifndef _mm_set_pd1
+// Looks like clang's emmintrin.h doesn't have this alternate name.
+// But _mm_set1_pd is an equivalent to _mm_set_pd1.
+#define _mm_set_pd1 _mm_set1_pd
+#endif
+
+
 #ifdef __SSEPE_INTEL_COMPILER
 
 inline __m128d& operator+=(__m128d& v1, const __m128d& v2){
diff --git a/Tests/Utils/testFmmAlgorithmProcRotation.cpp b/Tests/Utils/testFmmAlgorithmProcRotation.cpp
index c2487510a..5c98abd25 100644
--- a/Tests/Utils/testFmmAlgorithmProcRotation.cpp
+++ b/Tests/Utils/testFmmAlgorithmProcRotation.cpp
@@ -231,8 +231,9 @@ int main(int argc, char ** argv){
     typedef FRotationKernel< CellClass, ContainerClass,7 >     KernelClass;
 
     typedef FFmmAlgorithmThreadProc<OctreeClass,  CellClass, ContainerClass, KernelClass, LeafClass > FmmClass;
+#ifdef VALIDATE_FMM
     typedef FFmmAlgorithmThread<OctreeClass,  CellClass, ContainerClass, KernelClass, LeafClass > FmmClassNoProc;
-
+#endif
 
     ///////////////////////What we do/////////////////////////////
     std::cout << ">> This executable has to be used to test Proc Rotation algorithm.\n";
diff --git a/Tests/noDist/testP2PAvx.cpp b/Tests/noDist/testP2PAvx.cpp
index 9ba274b9a..d2ce867bf 100644
--- a/Tests/noDist/testP2PAvx.cpp
+++ b/Tests/noDist/testP2PAvx.cpp
@@ -125,7 +125,6 @@ int main(int argc, char ** argv){
 	// ----------------------------------------------------------------------------------------------------------
 	//                                   COMPUTATION
 	// ----------------------------------------------------------------------------------------------------------
-	FReal denergy = 0.0;
 	//
 	//  computation
 	//
diff --git a/Tests/noDist/testSphericalBlasBlockProc.cpp b/Tests/noDist/testSphericalBlasBlockProc.cpp
index 192d715e2..557b3fcdb 100644
--- a/Tests/noDist/testSphericalBlasBlockProc.cpp
+++ b/Tests/noDist/testSphericalBlasBlockProc.cpp
@@ -64,7 +64,6 @@ int main(int argc, char ** argv){
   typedef FSphericalBlockBlasKernel< CellClass, ContainerClass >     KernelClass;
 
   typedef FFmmAlgorithmThreadProc<OctreeClass,  CellClass, ContainerClass, KernelClass, LeafClass > FmmClass;
-  typedef FFmmAlgorithmThread<OctreeClass,  CellClass, ContainerClass, KernelClass, LeafClass > FmmClassNoProc;
 
 
   ///////////////////////What we do/////////////////////////////
diff --git a/UTests/utestMpiQs.cpp b/UTests/utestMpiQs.cpp
index 1862f9613..58062d716 100644
--- a/UTests/utestMpiQs.cpp
+++ b/UTests/utestMpiQs.cpp
@@ -122,7 +122,7 @@ class TestMpiQs : public FUTesterMpi<TestMpiQs> {
     ////////////////////////////////////////////////////////////
 
     void TestSmallSort(){
-        const int myRank = app.global().processId();
+        //const int myRank = app.global().processId();
         const int nbProcess = app.global().processCount();
 
         const int nbElements = nbProcess;
@@ -170,7 +170,7 @@ class TestMpiQs : public FUTesterMpi<TestMpiQs> {
     }
 
     void TestSameSort(){
-        const int myRank = app.global().processId();
+        //const int myRank = app.global().processId();
         const int nbProcess = app.global().processCount();
 
         const int nbElements = nbProcess * 100;
@@ -219,8 +219,8 @@ class TestMpiQs : public FUTesterMpi<TestMpiQs> {
     }
 
     void TestBigSort(){
-        const int myRank = app.global().processId();
-        const int nbProcess = app.global().processCount();
+        //const int myRank = app.global().processId();
+        //const int nbProcess = app.global().processCount();
 
         const int nbElements = 500;
         std::unique_ptr<long[]> elements(new long[nbElements]);
@@ -245,8 +245,8 @@ class TestMpiQs : public FUTesterMpi<TestMpiQs> {
 
 
     void TestPivotSort(){
-        const int myRank = app.global().processId();
-        const int nbProcess = app.global().processCount();
+        //const int myRank = app.global().processId();
+        //const int nbProcess = app.global().processCount();
 
         const int nbElements = 500;
         std::unique_ptr<long[]> elements(new long[nbElements]);
diff --git a/Utils/noDist/removeMoment.cpp b/Utils/noDist/removeMoment.cpp
index e1f046a78..b63c9b3fd 100755
--- a/Utils/noDist/removeMoment.cpp
+++ b/Utils/noDist/removeMoment.cpp
@@ -138,7 +138,7 @@ int main(int argc, char ** argv){
 	}
 	double boxsize[3] ;
 	FPoint centre ;
-	FSize numberofParticles ;
+    FSize numberofParticles = 0;
 	double energy = 0.0 ;
 	FmaRWParticle<8,8>*  particlesIn  ; //= new FmaRWParticle<8,8>[numberofParticles];
 	if( FParameters::existParameter(argc, argv, "-energy") ){
@@ -203,7 +203,7 @@ int main(int argc, char ** argv){
 
 	// const --> then shared
 	//
-	double totalCharge = 0.0, readEnergy;
+    double totalCharge = 0.0, readEnergy = 0.0;
 	//
 	for(int idxPart = 0 ; idxPart < numberofParticles; ++idxPart){
 		//
@@ -241,7 +241,7 @@ int main(int argc, char ** argv){
 	}
 	else if( FParameters::existParameter(argc, argv, "-FMM2Ewald") ){
 		preScaleEnergy  = 1.0 ;  postScaleEnergy = scaleEnergy ; preScaleForce = 1.0;  postScaleForce = scaleForce ;
-		coeffCorrection  = coeffCorrection;
+        //coeffCorrection  = coeffCorrection;
 	}
 	else {
 		std::cout << " -Ewald2FMM or -FMM2Ewald should be set"<<std::endl;
-- 
GitLab