macOS/M2 fixes
This commit is contained in:
parent
ee695b7243
commit
c65fcebaad
5 changed files with 25 additions and 15 deletions
7
Makefile
7
Makefile
|
@ -6,14 +6,15 @@ SHARED_LIB = libsparsemap.so
|
||||||
#CFLAGS = -Wall -Wextra -Wpedantic -Of -std=c11 -Iinclude/ -fPIC
|
#CFLAGS = -Wall -Wextra -Wpedantic -Of -std=c11 -Iinclude/ -fPIC
|
||||||
#CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -fPIC
|
#CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -fPIC
|
||||||
#CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -O0 -g -std=c11 -Iinclude/ -fPIC
|
#CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -O0 -g -std=c11 -Iinclude/ -fPIC
|
||||||
CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -fPIC
|
CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -fPIC
|
||||||
|
#CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -fPIC
|
||||||
#CFLAGS = -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -fPIC
|
#CFLAGS = -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -fPIC
|
||||||
#CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -Og -g -fsanitize=address,leak,object-size,pointer-compare,pointer-subtract,null,return,bounds,pointer-overflow,undefined -fsanitize-address-use-after-scope -std=c11 -Iinclude/ -fPIC
|
#CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -Og -g -fsanitize=address,leak,object-size,pointer-compare,pointer-subtract,null,return,bounds,pointer-overflow,undefined -fsanitize-address-use-after-scope -std=c11 -Iinclude/ -fPIC
|
||||||
#CFLAGS = -Wall -Wextra -Wpedantic -Og -g -fsanitize=all -fhardened -std=c11 -Iinclude/ -fPIC
|
#CFLAGS = -Wall -Wextra -Wpedantic -Og -g -fsanitize=all -fhardened -std=c11 -Iinclude/ -fPIC
|
||||||
|
|
||||||
#TEST_FLAGS = -DDEBUG -Wall -Wextra -Wpedantic -O0 -g -std=c11 -Iinclude/ -Itests/ -fPIC
|
#TEST_FLAGS = -DDEBUG -Wall -Wextra -Wpedantic -O0 -g -std=c11 -Iinclude/ -Itests/ -fPIC
|
||||||
TEST_FLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -Itests/ -fPIC
|
#TEST_FLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -Itests/ -fPIC
|
||||||
#TEST_FLAGS = -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -Itests/ -fPIC
|
TEST_FLAGS = -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -Itests/ -fPIC
|
||||||
#TEST_FLAGS = -DDEBUG -Wall -Wextra -Wpedantic -Og -g -fsanitize=address,leak,object-size,pointer-compare,pointer-subtract,null,return,bounds,pointer-overflow,undefined -fsanitize-address-use-after-scope -std=c11 -Iinclude/ -fPIC
|
#TEST_FLAGS = -DDEBUG -Wall -Wextra -Wpedantic -Og -g -fsanitize=address,leak,object-size,pointer-compare,pointer-subtract,null,return,bounds,pointer-overflow,undefined -fsanitize-address-use-after-scope -std=c11 -Iinclude/ -fPIC
|
||||||
|
|
||||||
TESTS = tests/test
|
TESTS = tests/test
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#define G2 0xAAAAAAAAAAAAAAAAULL // Every highest 2nd bit: 101010...
|
#define G2 0xAAAAAAAAAAAAAAAAULL // Every highest 2nd bit: 101010...
|
||||||
#define G4 0x3333333333333333ULL // 00110011 ... used to group the sum of 4 bits.
|
#define G4 0x3333333333333333ULL // 00110011 ... used to group the sum of 4 bits.
|
||||||
#define G8 0x0F0F0F0F0F0F0F0FULL
|
#define G8 0x0F0F0F0F0F0F0F0FULL
|
||||||
#define H8 0x8080808080808080ULL
|
#define H8 0x8080808080808080ULL
|
||||||
#define L9 0x0040201008040201ULL
|
#define L9 0x0040201008040201ULL
|
||||||
#define H9 (L9 << 8)
|
#define H9 (L9 << 8)
|
||||||
#define L16 0x0001000100010001ULL
|
#define L16 0x0001000100010001ULL
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
#define ONES_STEP_32 ( 0x0000000100000001ULL )
|
#define ONES_STEP_32 ( 0x0000000100000001ULL )
|
||||||
#define MSBS_STEP_32 ( 0x8000000080000000ULL )
|
#define MSBS_STEP_32 ( 0x8000000080000000ULL )
|
||||||
|
|
||||||
#define COMPARE_STEP_8(x,y) ( ( ( ( ( (x) | MSBS_STEP_8 ) - ( (y) & ~MSBS_STEP_8 ) ) ^ (x) ^ ~(y) ) & MSBS_STEP_8 ) >> 7 )
|
#define COMPARE_STEP_8(x,y) ( ( ( ( ( (x) | MSBS_STEP_8 ) - ( (y) & ~MSBS_STEP_8 ) ) ^ (x) ^ ~(y) ) & MSBS_STEP_8 ) >> 7 )
|
||||||
#define LEQ_STEP_8(x,y) ( ( ( ( ( (y) | MSBS_STEP_8 ) - ( (x) & ~MSBS_STEP_8 ) ) ^ (x) ^ (y) ) & MSBS_STEP_8 ) >> 7 )
|
#define LEQ_STEP_8(x,y) ( ( ( ( ( (y) | MSBS_STEP_8 ) - ( (x) & ~MSBS_STEP_8 ) ) ^ (x) ^ (y) ) & MSBS_STEP_8 ) >> 7 )
|
||||||
|
|
||||||
|
@ -72,4 +72,4 @@ inline int sux_popcountll(uint64_t x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _FASTRANK_POPCOUNT_H_ */
|
#endif /* _FASTRANK_POPCOUNT_H_ */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -814,7 +814,6 @@ __sm_get_size_impl(sparsemap_t *map)
|
||||||
return SM_SIZEOF_OVERHEAD + p - start;
|
return SM_SIZEOF_OVERHEAD + p - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/** @brief Aligns to SM_BITS_PER_VECTOR a given index \b idx.
|
/** @brief Aligns to SM_BITS_PER_VECTOR a given index \b idx.
|
||||||
*
|
*
|
||||||
* @param[in] idx The index to align.
|
* @param[in] idx The index to align.
|
||||||
|
@ -826,7 +825,6 @@ __sm_get_aligned_offset(size_t idx)
|
||||||
const size_t capacity = SM_BITS_PER_VECTOR;
|
const size_t capacity = SM_BITS_PER_VECTOR;
|
||||||
return (idx / capacity) * capacity;
|
return (idx / capacity) * capacity;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @brief Aligns to SM_CHUNK_MAP_CAPACITY a given index \b idx.
|
/** @brief Aligns to SM_CHUNK_MAP_CAPACITY a given index \b idx.
|
||||||
*
|
*
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#ifdef __x86_64__ // Check if running on x86_64 architecture
|
||||||
#ifdef X86_INTRIN
|
#ifdef X86_INTRIN
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <x86intrin.h>
|
#include <x86intrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../include/sparsemap.h"
|
#include "../include/sparsemap.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
@ -31,6 +33,7 @@
|
||||||
uint64_t
|
uint64_t
|
||||||
tsc(void)
|
tsc(void)
|
||||||
{
|
{
|
||||||
|
#ifdef __x86_64__ // Check if running on x86_64 architecture
|
||||||
#ifdef X86_INTRIN
|
#ifdef X86_INTRIN
|
||||||
return __rdtsc();
|
return __rdtsc();
|
||||||
#else
|
#else
|
||||||
|
@ -38,10 +41,18 @@ tsc(void)
|
||||||
__asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
|
__asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
|
||||||
return ((uint64_t)high << 32) | low;
|
return ((uint64_t)high << 32) | low;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __arm__ // Check if compiling for ARM architecture
|
||||||
|
uint64_t result;
|
||||||
|
__asm__ volatile("mrs %0, pmccntr_el0" : "=r"(result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
nsts()
|
nsts(void)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
|
@ -56,7 +67,7 @@ int __xorshift32_state = 0;
|
||||||
|
|
||||||
// Xorshift algorithm for PRNG
|
// Xorshift algorithm for PRNG
|
||||||
uint32_t
|
uint32_t
|
||||||
xorshift32()
|
xorshift32(void)
|
||||||
{
|
{
|
||||||
uint32_t x = __xorshift32_state;
|
uint32_t x = __xorshift32_state;
|
||||||
if (x == 0) {
|
if (x == 0) {
|
||||||
|
@ -70,7 +81,7 @@ xorshift32()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xorshift32_seed()
|
xorshift32_seed(void)
|
||||||
{
|
{
|
||||||
__xorshift32_state = XORSHIFT_SEED_VALUE;
|
__xorshift32_state = XORSHIFT_SEED_VALUE;
|
||||||
}
|
}
|
||||||
|
@ -350,7 +361,7 @@ print_bits(char *name, uint64_t value)
|
||||||
printf("%s\t", name);
|
printf("%s\t", name);
|
||||||
}
|
}
|
||||||
for (int i = 63; i >= 0; i--) {
|
for (int i = 63; i >= 0; i--) {
|
||||||
printf("%ld", (value >> i) & 1);
|
printf("%llu", (value >> i) & 1);
|
||||||
if (i % 8 == 0) {
|
if (i % 8 == 0) {
|
||||||
printf(" "); // Add space for better readability
|
printf(" "); // Add space for better readability
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,10 @@
|
||||||
|
|
||||||
uint64_t tsc(void);
|
uint64_t tsc(void);
|
||||||
double tsc_ticks_to_ns(uint64_t tsc_ticks);
|
double tsc_ticks_to_ns(uint64_t tsc_ticks);
|
||||||
double nsts();
|
double nsts(void);
|
||||||
|
|
||||||
void xorshift32_seed();
|
void xorshift32_seed(void);
|
||||||
uint32_t xorshift32();
|
uint32_t xorshift32(void);
|
||||||
|
|
||||||
void print_array(int *array, int l);
|
void print_array(int *array, int l);
|
||||||
void print_spans(int *array, int n);
|
void print_spans(int *array, int n);
|
||||||
|
|
Loading…
Reference in a new issue