aboutsummaryrefslogtreecommitdiff
path: root/src/cuda.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-03-17 17:17:14 +0100
committerdec05eba <dec05eba@protonmail.com>2023-03-17 17:17:14 +0100
commit93cb6593a642018e3373fb7099e1c0687b367176 (patch)
tree63d24dc3a9a03e71857ef793929f6000f75cc3db /src/cuda.c
parent8cbdb596ebf79587a432ed40583630b6cd39ed88 (diff)
Add overclocking option -oc to workaround a NVIDIA driver bug (forcefully set to p2 state when using cuda)
Diffstat (limited to 'src/cuda.c')
-rw-r--r--src/cuda.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/cuda.c b/src/cuda.c
index 3076ebe..470747b 100644
--- a/src/cuda.c
+++ b/src/cuda.c
@@ -2,8 +2,9 @@
#include "../include/library_loader.h"
#include <string.h>
-bool gsr_cuda_load(gsr_cuda *self) {
+bool gsr_cuda_load(gsr_cuda *self, Display *display, bool do_overclock) {
memset(self, 0, sizeof(gsr_cuda));
+ self->do_overclock = do_overclock;
dlerror(); /* clear */
void *lib = dlopen("libcuda.so.1", RTLD_LAZY);
@@ -76,6 +77,13 @@ bool gsr_cuda_load(gsr_cuda *self) {
goto fail;
}
+ if(self->do_overclock) {
+ if(gsr_overclock_load(&self->overclock, display))
+ gsr_overclock_start(&self->overclock);
+ else
+ fprintf(stderr, "gsr warning: gsr_cuda_load: failed to load xnvctrl, failed to overclock memory transfer rate\n");
+ }
+
self->library = lib;
return true;
@@ -91,8 +99,13 @@ void gsr_cuda_unload(gsr_cuda *self) {
self->cuCtxDestroy_v2(self->cu_ctx);
self->cu_ctx = 0;
}
-
dlclose(self->library);
- memset(self, 0, sizeof(gsr_cuda));
}
+
+ if(self->do_overclock && self->overclock.xnvctrl.library) {
+ gsr_overclock_stop(&self->overclock);
+ gsr_overclock_unload(&self->overclock);
+ }
+
+ memset(self, 0, sizeof(gsr_cuda));
}