Skip to content

Commit 7318b3b

Browse files
committed
Fix handling of EIATTR_EXIT_INSTR_OFFSETS & add libreCuCtxGetCurrent
1 parent 7c77584 commit 7318b3b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

driverapi/include/librecuda.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ LIBRECUDA_EXPORT libreCudaStatus_t libreCuCtxDestroy(LibreCUcontext ctx);
3636

3737
LIBRECUDA_EXPORT libreCudaStatus_t libreCuCtxSetCurrent(LibreCUcontext ctx);
3838

39+
LIBRECUDA_EXPORT libreCudaStatus_t libreCuCtxGetCurrent(LibreCUcontext *pCtxOut);
40+
3941
LIBRECUDA_EXPORT libreCudaStatus_t libreCuMemAlloc(void **pDevicePointer, size_t bytesize, bool mapToCpu = false);
4042

4143
LIBRECUDA_EXPORT libreCudaStatus_t libreCuMemCpy(void *dst, void *src, size_t byteCount, LibreCUstream stream);

driverapi/src/librecuda.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,8 +1119,7 @@ libreCudaStatus_t libreCuModuleLoadData(LibreCUmodule *pModule, const void *imag
11191119
break;
11201120
}
11211121
case EIATTR_EXIT_INSTR_OFFSETS: {
1122-
off += (EIATTR_EXIT_INSTR_OFFSETS_ATTR_WORD_LEN * sizeof(NvU32));
1123-
break;
1122+
goto parse_attrs_end;
11241123
}
11251124
default: {
11261125
// TODO: This isn't strictly correct,
@@ -1130,6 +1129,7 @@ libreCudaStatus_t libreCuModuleLoadData(LibreCUmodule *pModule, const void *imag
11301129
}
11311130
}
11321131
}
1132+
parse_attrs_end:;
11331133
}
11341134
}
11351135

@@ -1342,3 +1342,9 @@ libreCudaStatus_t libreCuDeviceGetName(char *pDeviceName, int length, LibreCUdev
13421342

13431343
LIBRECUDA_SUCCEED();
13441344
}
1345+
1346+
libreCudaStatus_t libreCuCtxGetCurrent(LibreCUcontext *pCtxOut) {
1347+
LIBRECUDA_VALIDATE(pCtxOut != nullptr, LIBRECUDA_ERROR_INVALID_VALUE);
1348+
*pCtxOut = current_ctx;
1349+
LIBRECUDA_SUCCEED();
1350+
}

0 commit comments

Comments
 (0)