Skip to content

Commit

Permalink
multi platform build
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-devv committed Apr 1, 2024
1 parent 907d875 commit e97c1e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 19 additions & 4 deletions crates/memonitor-sys/cuda/src/memonitor.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#include <stdlib.h>

#include <windows.h>

#include <memonitor.h>

const char *LIB_NAME = "nvcuda.dll";
#ifdef _WIN32

#include <windows.h>

#elif defined(__APPLE__)
// nothing
#else
include <dlfcn.h>
#endif

typedef int CUresult;
struct CUctx_st;
Expand Down Expand Up @@ -49,10 +55,19 @@ cuMemGetInfo_type cuMemGetInfo = NULL;


int cu_init() {
module = LoadLibraryA(LIB_NAME);
#ifdef _WIN32
module = LoadLibraryA("nvcuda.dll");
if (!module) {
return -1;
}
#elif defined(__APPLE__)
return -1;
#else
module = dlopen("libcuda.so", RTLD_NOW | RTLD_LOCAL);
if (!module) {
return -1;
}
#endif

cuInit = (cuInit_type) GetProcAddress(module, "cuInit");
cuCtxCreate = (cuCtxCreate_type) GetProcAddress(module, "cuCtxCreate");
Expand Down
2 changes: 2 additions & 0 deletions crates/memonitor-sys/vulkan/src/memonitor.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define __STDC_WANT_LIB_EXT1__ 1

#include <stdlib.h>
#include <string.h>

Expand Down

0 comments on commit e97c1e0

Please sign in to comment.