[med-svn] [Git][med-team/bolt-lmm][simde] Make more portable?

Nilesh Patra (@nilesh) gitlab at salsa.debian.org
Mon Aug 9 16:54:54 BST 2021



Nilesh Patra pushed to branch simde at Debian Med / bolt-lmm


Commits:
e0fce9c8 by Nilesh Patra at 2021-08-09T21:24:41+05:30
Make more portable?

- - - - -


1 changed file:

- debian/patches/simde.patch


Changes:

=====================================
debian/patches/simde.patch
=====================================
@@ -1,15 +1,21 @@
 --- a/src/MemoryUtils.hpp
 +++ b/src/MemoryUtils.hpp
-@@ -31,7 +31,8 @@
+@@ -31,8 +31,13 @@
  #include <mkl.h>
  #define ALIGNED_FREE mkl_free
  #else
 -#include <xmmintrin.h>
+-#define ALIGNED_FREE _mm_free
 +#define SIMDE_ENABLE_NATIVE_ALIASES
 +#include <simde/x86/sse.h>
- #define ALIGNED_FREE _mm_free
++inline void handmade_aligned_free(void *ptr)
++{
++  if (ptr) std::free(*(reinterpret_cast<void**>(ptr) - 1));
++}
++#define ALIGNED_FREE handmade_aligned_free
  #endif
  
+ #define ALIGNED_MALLOC_DOUBLES(numDoubles) (double *) ALIGNED_MALLOC((numDoubles)*sizeof(double))
 --- a/src/SnpData.cpp
 +++ b/src/SnpData.cpp
 @@ -25,9 +25,8 @@
@@ -24,3 +30,27 @@
  
  #include "Types.hpp"
  #include "SnpData.hpp"
+--- a/src/MemoryUtils.cpp
++++ b/src/MemoryUtils.cpp
+@@ -22,11 +22,20 @@
+ #include "MemoryUtils.hpp"
+ #include "Types.hpp"
+ 
++inline void* handmade_aligned_malloc(std::size_t size, std::size_t memsize)
++{
++ void *original = std::malloc(size+memsize);
++ if (original == 0) return 0;
++ void *aligned = reinterpret_cast<void*>((reinterpret_cast<std::size_t>(original) & ~(std::size_t(memsize-1))) + memsize);
++ *(reinterpret_cast<void**>(aligned) - 1) = original;
++ return aligned;
++}
++
+ void *ALIGNED_MALLOC(uint64 size) {
+ #ifdef USE_MKL_MALLOC
+   void *p = mkl_malloc(size, MEM_ALIGNMENT);
+ #else
+-  void *p = _mm_malloc(size, MEM_ALIGNMENT);
++  void *p = handmade_aligned_malloc(size, MEM_ALIGNMENT);
+ #endif
+   // TODO: change to assert() or dispense with altogether and change ALIGNED_MALLOC to macro?
+   if (p == NULL) {



View it on GitLab: https://salsa.debian.org/med-team/bolt-lmm/-/commit/e0fce9c84014768b5c45431c2033706b2bf1a029

-- 
View it on GitLab: https://salsa.debian.org/med-team/bolt-lmm/-/commit/e0fce9c84014768b5c45431c2033706b2bf1a029
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20210809/2ed8550a/attachment-0001.htm>


More information about the debian-med-commit mailing list