Use mkl_malloc when use mkl
authorTomasz Socha <tomasz.socha@intel.com>
Thu, 8 Dec 2016 13:51:30 +0000 (14:51 +0100)
committerTomasz Socha <tomasz.socha@intel.com>
Wed, 21 Dec 2016 12:19:24 +0000 (13:19 +0100)
include/caffe/syncedmem.hpp

index 38ee466..6474a69 100644 (file)
@@ -3,6 +3,10 @@
 
 #include <cstdlib>
 
+#ifdef USE_MKL
+  #include "mkl.h"
+#endif
+
 #include "caffe/common.hpp"
 
 namespace caffe {
@@ -20,7 +24,11 @@ inline void CaffeMallocHost(void** ptr, size_t size, bool* use_cuda) {
     return;
   }
 #endif
+#ifdef USE_MKL
+  *ptr = mkl_malloc(size ? size:1, 64);
+#else
   *ptr = malloc(size);
+#endif
   *use_cuda = false;
   CHECK(*ptr) << "host allocation of size " << size << " failed";
 }
@@ -32,7 +40,11 @@ inline void CaffeFreeHost(void* ptr, bool use_cuda) {
     return;
   }
 #endif
+#ifdef USE_MKL
+  mkl_free(ptr);
+#else
   free(ptr);
+#endif
 }