Skip to content

Commit 4bef39a

Browse files
committed
Added profiler
1 parent 6d8e212 commit 4bef39a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

driverapi/src/librecuda.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <set>
4242
#include <unordered_map>
4343
#include <unordered_set>
44+
#include <cassert>
4445

4546
#define GPU_FIFO_AREA_SIZE 0x200000
4647

@@ -241,7 +242,12 @@ static inline NvU64 maxOf(NvU64 a, NvU64 b) {
241242
}
242243

243244
NvU64 bump_alloc_virtual_addr(LibreCUcontext ctx, size_t size, NvU32 alignment = 4 << 10) {
244-
NvU64 va_address = ceilDiv(ctx->uvm_vaddr, alignment) * alignment;
245+
NvU64 va_address = ctx->uvm_vaddr;
246+
NvU64 slack = va_address % alignment;
247+
if (slack != 0) {
248+
va_address += (alignment - slack);
249+
}
250+
assert(va_address % alignment == 0);
245251
ctx->uvm_vaddr = va_address + size;
246252
return va_address;
247253
}

0 commit comments

Comments
 (0)