diff --git a/c/glm.c b/c/glm.c index ed9cbea..297b964 100644 --- a/c/glm.c +++ b/c/glm.c @@ -27,10 +27,10 @@ #include /* PIPE ready-flags/job queue + PILOT_REAL cross-layer handshake */ #include /* sched_yield: PIPE spin / PILOT barrier */ #include -#if defined(__APPLE__) || defined(__linux__) +#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) #include /* select() serve-loop polling (#68); not on native MinGW */ #endif -#if defined(__APPLE__) || defined(__linux__) +#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) #include #include /* mlock: inchioda le pagine in RAM / wire pages into RAM */ #include /* fstat per mmap degli shard (COLI_MMAP) */ @@ -1286,7 +1286,7 @@ static void *map_of_fd(int fd){ pthread_mutex_lock(&g_map_mtx); for(int i=0;ioff; size_t n=(size_t)tw[k]->nbytes; -#if defined(__APPLE__) || defined(__linux__) +#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) madvise((void*)((uintptr_t)p & ~16383UL), n+16384, MADV_WILLNEED); #endif volatile char acc=0; @@ -1562,7 +1562,7 @@ static inline void pipe_wait(int q){ #ifdef COLI_CUDA static void expert_host_release(Model *m, ESlot *s){ if(!s->slab&&!s->fslab) return; -#if defined(__APPLE__) || defined(__linux__) +#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) if(s->slab) munlock(s->slab,(size_t)s->slab_cap); if(s->fslab) munlock(s->fslab,(size_t)s->fslab_cap*sizeof(float)); #elif defined(_WIN32) @@ -3900,7 +3900,7 @@ static void run_serve_mux(Model *m, const char *snap){ * the Windows equivalent: it reports bytes available without reading. */ int ready=0; if(!eof){ -#if defined(__APPLE__) || defined(__linux__) +#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) fd_set rfds; FD_ZERO(&rfds); FD_SET(STDIN_FILENO,&rfds); struct timeval tv={0,0}, *ptv=active?&tv:NULL; ready=select(STDIN_FILENO+1,&rfds,NULL,NULL,ptv); @@ -4309,7 +4309,7 @@ static int mem_should_wire(void){ /* Inchioda [addr,addr+len) in RAM fisica. No-op fuori da POSIX (Windows ecc.). * EN: wire [addr,addr+len) into physical RAM. No-op off POSIX (Windows, etc.). */ static int mem_wire(void *addr, size_t len){ -#if defined(__APPLE__) || defined(__linux__) +#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) return mlock(addr, len); #elif defined(_WIN32) return compat_mlock(addr, len); /* VirtualLock + working-set growth */ @@ -4583,6 +4583,11 @@ int main(int argc, char **argv){ fprintf(stderr,"[OMP] hot-thread tuning: re-exec once (COLI_NO_OMP_TUNE=1 to skip)\n"); execv("/proc/self/exe", argv); /* returns only on failure -> fall through and run untuned */ perror("[OMP] execv self-reexec failed, running untuned"); +#endif +#ifdef __FreeBSD__ + fprintf(stderr,"[OMP] hot-thread tuning: re-exec once (COLI_NO_OMP_TUNE=1 to skip)\n"); + execv("/proc/curproc/file", argv); /* returns only on failure -> fall through and run untuned */ + perror("[OMP] execv self-reexec failed, running untuned"); #endif } #if defined(__AVX512F__) && defined(__AVX512BW__) diff --git a/c/olmoe.c b/c/olmoe.c index 1c5ffaa..5923bde 100644 --- a/c/olmoe.c +++ b/c/olmoe.c @@ -12,7 +12,7 @@ #include #include #include -#if defined(__APPLE__) || defined(__linux__) +#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) #include #endif #include "st.h"