Skip to content

Commit

Permalink
Also simplified the aligned memory allocation functions for tiny ocl
Browse files Browse the repository at this point in the history
  • Loading branch information
maniatic0 committed Nov 23, 2024
1 parent f75fdcb commit 2227629
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions tiny_ocl.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,9 @@ inline void* malloc64( size_t size, void* = nullptr )
}
inline void free64( void* ptr, void* = nullptr ) { _aligned_free( ptr ); }
}
#elif defined(__EMSCRIPTEN__) // EMSCRIPTEN - needs to be before gcc and clang to avoid misdetection
#else // EMSCRIPTEN / gcc / clang
#define ALIGNED( x ) __attribute__( ( aligned( x ) ) )
#if defined(__wasm_simd128__) || defined(__wasm_relaxed_simd__)
// https://emscripten.org/docs/porting/simd.html
#include <xmmintrin.h>
namespace tinyocl {
inline void* malloc64( size_t size, void* = nullptr )
{
return size == 0 ? 0 : _mm_malloc( size, 64 );
}
inline void free64( void* ptr, void* = nullptr ) { _mm_free( ptr ); }
}
#else
namespace tinyocl {
inline void* malloc64( size_t size, void* = nullptr )
{
return size == 0 ? 0 : aligned_alloc( 64, make_multiple_64( size ) );
}
inline void free64( void* ptr, void* = nullptr ) { free( ptr ); }
}
#endif
#else // gcc / clang
#define ALIGNED( x ) __attribute__( ( aligned( x ) ) )
#if defined(__x86_64__) || defined(_M_X64)
#if defined(__x86_64__) || defined(_M_X64) || defined(__wasm_simd128__) || defined(__wasm_relaxed_simd__)
#include <xmmintrin.h>
namespace tinyocl {
inline void* malloc64( size_t size, void* = nullptr )
Expand Down

0 comments on commit 2227629

Please sign in to comment.