Browse Source

fix(mgb): fix the compatibility issue of cuda stub with older version drivers

GitOrigin-RevId: 628afbf3cf
dev-support-lite-fork-debug-mode
Megvii Engine Team 2 years ago
parent
commit
1404437a90
7 changed files with 48 additions and 8 deletions
  1. +1
    -1
      dnn/cuda-stub/src/dlopen_helper.h
  2. +9
    -1
      dnn/cuda-stub/src/libcuda-wrap_10.1.h
  3. +9
    -1
      dnn/cuda-stub/src/libcuda-wrap_10.2.h
  4. +9
    -1
      dnn/cuda-stub/src/libcuda-wrap_11.1.h
  5. +9
    -1
      dnn/cuda-stub/src/libcuda-wrap_11.2.h
  6. +9
    -1
      dnn/cuda-stub/src/libcuda-wrap_11.4.h
  7. +2
    -2
      dnn/cuda-stub/src/libcuda.cpp

+ 1
- 1
dnn/cuda-stub/src/dlopen_helper.h View File

@@ -111,7 +111,7 @@ static void* resolve_library_func(void* handle, const char* func) {
}
auto ret = dlsym(handle, func);
if (!ret) {
LOGD("failed to load %s func: %s", g_default_api_name, func);
LOGD("failed to load %s func: %s.(It seems that the currently used version of the library containing the function is too old.)", g_default_api_name, func);
}
return ret;
}

+ 9
- 1
dnn/cuda-stub/src/libcuda-wrap_10.1.h View File

@@ -3829,6 +3829,7 @@ static void load_library() {
return;

void* handle = get_library_handle();
int num = 0;
for (size_t i = 0; i < NR_FUNC; ++i) {
void* func;
if (!handle) {
@@ -3837,10 +3838,17 @@ static void load_library() {
func = resolve_library_func(handle, g_func_name[i]);
}
if (!func) {
func = g_func_table_error[i];
break;
}
num++;
__atomic_store_n(g_func_table + i, func, __ATOMIC_RELAXED);
}
if (num != NR_FUNC) {
for (size_t i = 0; i < NR_FUNC; ++i) {
void* func = g_func_table_error[i];
__atomic_store_n(g_func_table + i, func, __ATOMIC_RELAXED);
}
}
done = true;
}



+ 9
- 1
dnn/cuda-stub/src/libcuda-wrap_10.2.h View File

@@ -3999,6 +3999,7 @@ static void load_library() {
return;

void* handle = get_library_handle();
int num = 0;
for (size_t i = 0; i < NR_FUNC; ++i) {
void* func;
if (!handle) {
@@ -4007,10 +4008,17 @@ static void load_library() {
func = resolve_library_func(handle, g_func_name[i]);
}
if (!func) {
func = g_func_table_error[i];
break;
}
num++;
__atomic_store_n(g_func_table + i, func, __ATOMIC_RELAXED);
}
if (num != NR_FUNC) {
for (size_t i = 0; i < NR_FUNC; ++i) {
void* func = g_func_table_error[i];
__atomic_store_n(g_func_table + i, func, __ATOMIC_RELAXED);
}
}
done = true;
}



+ 9
- 1
dnn/cuda-stub/src/libcuda-wrap_11.1.h View File

@@ -4369,6 +4369,7 @@ static void load_library() {
return;

void* handle = get_library_handle();
int num = 0;
for (size_t i = 0; i < NR_FUNC; ++i) {
void* func;
if (!handle) {
@@ -4377,10 +4378,17 @@ static void load_library() {
func = resolve_library_func(handle, g_func_name[i]);
}
if (!func) {
func = g_func_table_error[i];
break;
}
num++;
__atomic_store_n(g_func_table + i, func, __ATOMIC_RELAXED);
}
if (num != NR_FUNC) {
for (size_t i = 0; i < NR_FUNC; ++i) {
void* func = g_func_table_error[i];
__atomic_store_n(g_func_table + i, func, __ATOMIC_RELAXED);
}
}
done = true;
}



+ 9
- 1
dnn/cuda-stub/src/libcuda-wrap_11.2.h View File

@@ -4659,6 +4659,7 @@ static void load_library() {
return;

void* handle = get_library_handle();
int num = 0;
for (size_t i = 0; i < NR_FUNC; ++i) {
void* func;
if (!handle) {
@@ -4667,10 +4668,17 @@ static void load_library() {
func = resolve_library_func(handle, g_func_name[i]);
}
if (!func) {
func = g_func_table_error[i];
break;
}
num++;
__atomic_store_n(g_func_table + i, func, __ATOMIC_RELAXED);
}
if (num != NR_FUNC) {
for (size_t i = 0; i < NR_FUNC; ++i) {
void* func = g_func_table_error[i];
__atomic_store_n(g_func_table + i, func, __ATOMIC_RELAXED);
}
}
done = true;
}



+ 9
- 1
dnn/cuda-stub/src/libcuda-wrap_11.4.h View File

@@ -4899,6 +4899,7 @@ static void load_library() {
return;

void* handle = get_library_handle();
int num = 0;
for (size_t i = 0; i < NR_FUNC; ++i) {
void* func;
if (!handle) {
@@ -4907,10 +4908,17 @@ static void load_library() {
func = resolve_library_func(handle, g_func_name[i]);
}
if (!func) {
func = g_func_table_error[i];
break;
}
num++;
__atomic_store_n(g_func_table + i, func, __ATOMIC_RELAXED);
}
if (num != NR_FUNC) {
for (size_t i = 0; i < NR_FUNC; ++i) {
void* func = g_func_table_error[i];
__atomic_store_n(g_func_table + i, func, __ATOMIC_RELAXED);
}
}
done = true;
}



+ 2
- 2
dnn/cuda-stub/src/libcuda.cpp View File

@@ -3,8 +3,8 @@
#pragma GCC visibility push(default)

#include <cstdio>
#define LOGI(fmt, v...) fprintf(stdout, "info: " fmt "\n", ##v)
#define LOGD(fmt, v...) fprintf(stdout, "debug: " fmt "\n", ##v)
#define LOGI(fmt, v...) fprintf(stderr, "info: " fmt "\n", ##v)
#define LOGD(fmt, v...) fprintf(stderr, "debug: " fmt "\n", ##v)

extern "C" {
#include "cuda.h"


Loading…
Cancel
Save