Commits

Jacob Hinkle  committed efd5d33 Merge

Merge branch 'master' of bitbucket.org:scicompanat/pyca

  • Participants
  • Parent commits 6c10965, 8afd856

Comments (0)

Files changed (14)

File Code/Cxx/inc/alg/FluidKernelFFTInterface.h

 class FluidKernelFFTInterface {
 public:
    // parameters:
+   virtual ~FluidKernelFFTInterface() = 0;
    virtual void setAlpha(float alpha) = 0;
    virtual float getAlpha() = 0;
    virtual void setBeta(float beta) = 0;
 
 };
 
+ inline FluidKernelFFTInterface::~FluidKernelFFTInterface(){}
+
 } // end namespace PyCA
 
 #endif // __FLUID_KERNEL_FFT_INTERFACE_H__

File Code/Cxx/inc/alg/GaussianFilterInterface.h

 class GaussianFilterInterface {
 
 public:
+    virtual ~GaussianFilterInterface() = 0;
     virtual void updateParams(const Vec3Di& size, 
 		      const Vec3Df& sig, 
 		      const Vec3Di kRad) = 0;
 
 };
 
+ inline GaussianFilterInterface::~GaussianFilterInterface(){}
+
 } // end namespace PyCA
 
 #endif // __GAUSSIAN_FILTER_INTERFACE_H__

File Code/Cxx/inc/alg/MultiscaleResamplerInterface.h

 class MultiscaleResamplerInterface
 {
 public:
+    virtual ~MultiscaleResamplerInterface() = 0;
     virtual const MultiscaleManager &getScaleManager() const = 0;
 
    /**
 			      StreamT stream=NULL) const = 0;
 };
 
+ inline MultiscaleResamplerInterface::~MultiscaleResamplerInterface(){}
+
 } // end namespace PyCA
 
 #endif // __MULTISCALE_RESAMPLER_INTERFACE_H__

File Code/Cxx/inc/base/MemoryManager.h

 
 #endif // SWIG
 
+#include <PyCAThread.h>
+
 #define MM_ID_NONE ((size_t)-1)
 
 namespace PyCA {
     friend class ManagedField3D;
 };
 
-// swig doesn't like __thread
-#ifdef SWIG
-#define __thread
-#endif
-// MSVC prefers __declspec(thread) instead of __thread
-#ifdef _MSC_VER
-#define __thread __declspec(thread)
-#endif
-  
 /**
  * Creates a per-thread MemoryManager
  */

File Code/Cxx/inc/base/PyCAThread.h

 #ifndef __PYCA_THREAD_H__
 #define __PYCA_THREAD_H__
 
+// swig doesn't like __thread
+#ifdef SWIG
+#define __thread
+#endif
+// MSVC prefers __declspec(thread) instead of __thread
+#ifdef _MSC_VER
+#define __thread __declspec(thread)
+#endif
+
+// the rest of this isn't needed by SWIG
 #ifndef SWIG
 
 #include <string>
 
 #if defined(_MSC_VER)
 #include <windows.h>
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) || defined(__clang__)
 #include <pthread.h>
 #endif
 
-#endif // SWIG
-
 namespace PyCA {
 
-#if defined(_MSC_VER)
+#if defined _MSC_VER
 typedef DWORD ThreadID;
 typedef HANDLE Mutex;
 #define PYCA_MUTEX_INITIALIZER CreateMutex(NULL,FALSE,NULL)
-#elif defined(__GNUC__)
+#elif defined __GNUC__ || defined __clang__
 typedef pthread_t ThreadID;
 typedef pthread_mutex_t Mutex;
 #define PYCA_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
 } // end namespace PyCA
 
+#endif // SWIG
+
 #endif // __PYCA_THREAD_H__

File Code/Cxx/inc/base/Reduce.h

 #include <estream.h>
 #include <Selector.h>
 
-// MSVC prefers __declspec(thread) instead of __thread
-#ifdef _MSC_VER
-#define __thread __declspec(thread)
-#endif
+#include <PyCAThread.h>
 
 namespace PyCA {
 

File Code/Cxx/inc/base/log.h

 {
   typedef std::map<ThreadID, std::string> ThreadNameMap;
 public:
-  Log(const char *file, int line);
+  Log(const char *file="unknown file", int line=0);
   virtual ~Log();
   std::ostringstream& Get(TLogLevel level = logINFO, bool printNode = false, bool printThread = false);
 public:
 }
 
 template <typename T>
-Log<T>::Log(const char *file="unknown file", int line=0)
+Log<T>::Log(const char *file, int line)
   :  mFile(file),
      mLine(line)
 {

File Code/Cxx/src/CMakeLists.txt

   ENDFOREACH(CDEF)
   #MESSAGE(STATUS "Compiler Defs: ${DEF_FLAGS}")
 
-  IF(CMAKE_COMPILER_IS_GNUCC)
-      ADD_CUSTOM_COMMAND(
-        OUTPUT ${TPL_PROC_FILE}
-        # TODO: Need to find cpp using cmake instead of assuming it's in $PATH
-        COMMAND ${CMAKE_CXX_COMPILER} ${DEF_FLAGS} -E -x c ${TPL_FILE} -o ${TPL_PROC_FILE}
-        MAIN_DEPENDENCY ${TPL_FILE}
-        VERBATIM)
-  ELSEIF(MSVC)
-      ADD_CUSTOM_COMMAND(
-        OUTPUT ${TPL_PROC_FILE}
-        # TODO: Need to find cpp using cmake instead of assuming it's in $PATH
-        COMMAND ${CMAKE_CXX_COMPILER} ${DEF_FLAGS} /P ${TPL_FILE} /Fi${TPL_PROC_FILE}
-        MAIN_DEPENDENCY ${TPL_FILE}
-        VERBATIM)
+  IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
+      CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+    ADD_CUSTOM_COMMAND(
+      OUTPUT ${TPL_PROC_FILE}
+      # TODO: Need to find cpp using cmake instead of assuming it's in $PATH
+      COMMAND ${CMAKE_CXX_COMPILER} ${DEF_FLAGS} -E -x c ${TPL_FILE} -o ${TPL_PROC_FILE}
+      MAIN_DEPENDENCY ${TPL_FILE}
+      VERBATIM)
+  ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+    ADD_CUSTOM_COMMAND(
+      OUTPUT ${TPL_PROC_FILE}
+      # TODO: Need to find cpp using cmake instead of assuming it's in $PATH
+      COMMAND ${CMAKE_CXX_COMPILER} ${DEF_FLAGS} /P ${TPL_FILE} /Fi${TPL_PROC_FILE}
+      MAIN_DEPENDENCY ${TPL_FILE}
+      VERBATIM)
   ENDIF()
 
   ADD_CUSTOM_COMMAND(

File Code/Cxx/src/alg/FluidKernelFFTBase.cxx

 
 // MSVC lacks a few constants and math functions
 #ifdef _MSC_VER
-#define M_PI 3.14159
+#define M_PI 3.141592653589793
 #endif
 
 namespace PyCA {

File Code/Cxx/src/base/PyCAThread.cxx

 
 void mutex_lock(Mutex *m){ WaitForSingleObject(*m, INFINITE); }
 void mutex_unlock(Mutex *m){ ReleaseMutex(*m); }
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) || defined(__clang__)
 ThreadID current_thread_id(){ return pthread_self(); }
 bool compare_threads(ThreadID t1, ThreadID t2){ return pthread_equal(t1, t2); }
 

File Code/Cxx/src/math/CFieldOpers.cxx

 template void CFieldOpers::
 FixedPointInverse<BACKGROUND_STRATEGY_WRAP>(Field3D &ginv, const Field3D& g, unsigned int numIter, StreamT stream, bool onDev);
 
-#ifndef _MSC_VER
-// Fix MSVC complaining about a redeclaration here. Not sure why it is -JDH Nov 2013
-void CFieldOpers::UpdateInverse(Field3D &ginv0t1,Field3D &scratchV, const Field3D& ginv0t, const Field3D& w, unsigned int numIter, StreamT stream, bool onDev);
-#endif
+// #ifndef _MSC_VER
+// // Fix MSVC complaining about a redeclaration here. Not sure why it is -JDH Nov 2013
+// void CFieldOpers::UpdateInverse(Field3D &ginv0t1,Field3D &scratchV, const Field3D& ginv0t, const Field3D& w, unsigned int numIter, StreamT stream, bool onDev);
+// #endif
 
 template void CFieldOpers::
 Ad<BACKGROUND_STRATEGY_ZERO>(Field3D& Z, const Field3D& g, const Field3D& X, StreamT s,bool onDev);

File Code/Cxx/src/math/FieldOpers_inst.tpl

 FixedPointInverse<${IDBG}>(Field3D&, const Field3D&, unsigned int, StreamT, bool);
 
 template void FieldOpers<${ExecMode}>::
-UpdateInverse(Field3D&, Field3D&, const Field3D&, const Field3D&, unsigned int, StreamT, bool);
-
-template void FieldOpers<${ExecMode}>::
 Ad<${VOperBG}>(Field3D&, const Field3D&, const Field3D&, StreamT, bool);
 
 template void FieldOpers<${ExecMode}>::

File Code/Cxx/src/thread/ThreadIdentity.cxx

  * ================================================================ */
 
 #include <ThreadIdentity.h>
+#include <PyCAThread.h>
 
 #if defined _MSC_VER
+
 #include <windows.h>
 #define ATOMICINC(x) InterlockedIncrement(&x);
-#else
-#define ATOMICINC(x) __sync_fetch_and_add(&x, 1);
+
+#elif defined __GNUC__
+
 #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))
 #include <ext/atomicity.h>
 #else
 #include <bits/atomicity.h>
 #endif
-#endif
+#define ATOMICINC(x) __sync_fetch_and_add(&x, 1);
+
+#elif defined __clang__
+
+#include <libkern/OSAtomic.h>
+#define ATOMICINC(x) OSAtomicIncrement32Barrier(const_cast<int*>(x));
 
-// swig doesn't like __thread
-#ifdef SWIG
-#define __thread
-#endif
-// MSVC prefers __declspec(thread) instead of __thread
-#ifdef _MSC_VER
-#define __thread __declspec(thread)
 #endif
 
 namespace PyCA {

File Code/Cxx/src/types/estream.cxx

 
 #include <conditionMacro.h>
 
+#include <PyCAThread.h>
+
 #ifdef CUDA_ENABLED
 #include <cuda_runtime_api.h>
 #endif
 
-// swig doesn't like __thread
-#ifdef SWIG
-#define __thread
-#endif
-// MSVC prefers __declspec(thread) instead of __thread
-#ifdef _MSC_VER
-#define __thread __declspec(thread)
-#endif
-
 namespace PyCA {
 
 // This variable is global per-thread