Patch 2: Added threading for non posix systems
This commit is contained in:
parent
68623ee175
commit
8a7dd2c682
2 changed files with 2703 additions and 2695 deletions
11
ggml.h
11
ggml.h
|
@ -776,13 +776,20 @@ int ggml_cpu_has_vsx(void);
|
|||
//
|
||||
// threading for non posix systems
|
||||
//
|
||||
|
||||
#if defined(_WIN32) && !defined(_POSIX_THREADS)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_THREADS
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
typedef HANDLE pthread_t;
|
||||
typedef DWORD thread_ret_t;
|
||||
static int pthread_create(pthread_t* out, void* unused, thread_ret_t(*func)(void*), void* arg);
|
||||
static int pthread_create(pthread_t* out, void* unused, void*(*func)(void*), void* arg);
|
||||
static int pthread_join(pthread_t thread, void* unused);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -325,6 +325,7 @@ static void *mmap_file(const char *fname, uint64_t *mm_length) {
|
|||
the_load_file_to_standby_struct * the_load_file_to_standby_struct1 = 0;
|
||||
const size_t readstridelen = 1 << 20;
|
||||
size_t fnamelen = strlen(fname);
|
||||
pthread_t threadId;
|
||||
#if defined(_WIN32) && !defined(_POSIX_MAPPED_FILES)
|
||||
HANDLE hFile = CreateFileA(fname,
|
||||
GENERIC_READ,
|
||||
|
@ -382,7 +383,7 @@ the_load_file_to_standby_struct * the_load_file_to_standby_struct1 = 0;
|
|||
if(the_load_file_to_standby_struct1->fname){
|
||||
memcpy(the_load_file_to_standby_struct1->fname, fname, fnamelen);
|
||||
}
|
||||
pthread_create(0, 0, (void *(*)(void*))(&load_file_to_standby), the_load_file_to_standby_struct1);
|
||||
pthread_create(&threadId, 0, (void*(*)(void*))(&load_file_to_standby), the_load_file_to_standby_struct1);
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue