FreeBSD compatibility: platform guards in glm.c/olmoe.c (#206)
This commit is contained in:
@@ -27,10 +27,10 @@
|
|||||||
#include <stdatomic.h> /* PIPE ready-flags/job queue + PILOT_REAL cross-layer handshake */
|
#include <stdatomic.h> /* PIPE ready-flags/job queue + PILOT_REAL cross-layer handshake */
|
||||||
#include <sched.h> /* sched_yield: PIPE spin / PILOT barrier */
|
#include <sched.h> /* sched_yield: PIPE spin / PILOT barrier */
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#if defined(__APPLE__) || defined(__linux__)
|
#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__)
|
||||||
#include <sys/select.h> /* select() serve-loop polling (#68); not on native MinGW */
|
#include <sys/select.h> /* select() serve-loop polling (#68); not on native MinGW */
|
||||||
#endif
|
#endif
|
||||||
#if defined(__APPLE__) || defined(__linux__)
|
#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__)
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <sys/mman.h> /* mlock: inchioda le pagine in RAM / wire pages into RAM */
|
#include <sys/mman.h> /* mlock: inchioda le pagine in RAM / wire pages into RAM */
|
||||||
#include <sys/stat.h> /* fstat per mmap degli shard (COLI_MMAP) */
|
#include <sys/stat.h> /* fstat per mmap degli shard (COLI_MMAP) */
|
||||||
@@ -1286,7 +1286,7 @@ static void *map_of_fd(int fd){
|
|||||||
pthread_mutex_lock(&g_map_mtx);
|
pthread_mutex_lock(&g_map_mtx);
|
||||||
for(int i=0;i<g_nmaps;i++) if(g_maps[i].fd==fd){ void *b=g_maps[i].base; pthread_mutex_unlock(&g_map_mtx); return b; }
|
for(int i=0;i<g_nmaps;i++) if(g_maps[i].fd==fd){ void *b=g_maps[i].base; pthread_mutex_unlock(&g_map_mtx); return b; }
|
||||||
void *base=NULL;
|
void *base=NULL;
|
||||||
#if defined(__APPLE__) || defined(__linux__)
|
#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__)
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(g_nmaps<512 && fstat(fd,&st)==0){
|
if(g_nmaps<512 && fstat(fd,&st)==0){
|
||||||
size_t len=((size_t)st.st_size+16383)&~(size_t)16383;
|
size_t len=((size_t)st.st_size+16383)&~(size_t)16383;
|
||||||
@@ -1358,7 +1358,7 @@ static int expert_load(Model *m, int layer, int eid, ESlot *s, int fatal){
|
|||||||
* residency. This is pread's I/O without the copy and without the slab. */
|
* residency. This is pread's I/O without the copy and without the slab. */
|
||||||
for(int k=0;k<3;k++){
|
for(int k=0;k<3;k++){
|
||||||
char *p=(char*)bw[k]+tw[k]->off; size_t n=(size_t)tw[k]->nbytes;
|
char *p=(char*)bw[k]+tw[k]->off; 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);
|
madvise((void*)((uintptr_t)p & ~16383UL), n+16384, MADV_WILLNEED);
|
||||||
#endif
|
#endif
|
||||||
volatile char acc=0;
|
volatile char acc=0;
|
||||||
@@ -1562,7 +1562,7 @@ static inline void pipe_wait(int q){
|
|||||||
#ifdef COLI_CUDA
|
#ifdef COLI_CUDA
|
||||||
static void expert_host_release(Model *m, ESlot *s){
|
static void expert_host_release(Model *m, ESlot *s){
|
||||||
if(!s->slab&&!s->fslab) return;
|
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->slab) munlock(s->slab,(size_t)s->slab_cap);
|
||||||
if(s->fslab) munlock(s->fslab,(size_t)s->fslab_cap*sizeof(float));
|
if(s->fslab) munlock(s->fslab,(size_t)s->fslab_cap*sizeof(float));
|
||||||
#elif defined(_WIN32)
|
#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. */
|
* the Windows equivalent: it reports bytes available without reading. */
|
||||||
int ready=0;
|
int ready=0;
|
||||||
if(!eof){
|
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);
|
fd_set rfds; FD_ZERO(&rfds); FD_SET(STDIN_FILENO,&rfds);
|
||||||
struct timeval tv={0,0}, *ptv=active?&tv:NULL;
|
struct timeval tv={0,0}, *ptv=active?&tv:NULL;
|
||||||
ready=select(STDIN_FILENO+1,&rfds,NULL,NULL,ptv);
|
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.).
|
/* 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.). */
|
* EN: wire [addr,addr+len) into physical RAM. No-op off POSIX (Windows, etc.). */
|
||||||
static int mem_wire(void *addr, size_t len){
|
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);
|
return mlock(addr, len);
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
return compat_mlock(addr, len); /* VirtualLock + working-set growth */
|
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");
|
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 */
|
execv("/proc/self/exe", argv); /* returns only on failure -> fall through and run untuned */
|
||||||
perror("[OMP] execv self-reexec failed, running 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
|
#endif
|
||||||
}
|
}
|
||||||
#if defined(__AVX512F__) && defined(__AVX512BW__)
|
#if defined(__AVX512F__) && defined(__AVX512BW__)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#if defined(__APPLE__) || defined(__linux__)
|
#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__)
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#endif
|
#endif
|
||||||
#include "st.h"
|
#include "st.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user