From 2d744fd2b1a5e15fd1d5cada50c64edf502f8938 Mon Sep 17 00:00:00 2001 From: Brodey Newman Date: Thu, 19 Dec 2024 03:54:59 +0000 Subject: [PATCH] chore: manual server --- codegen/manual_server.cpp | 53 +++++++++++++++++++++++++++++++++++++++ codegen/manual_server.h | 2 ++ 2 files changed, 55 insertions(+) diff --git a/codegen/manual_server.cpp b/codegen/manual_server.cpp index c9a8130..186e554 100755 --- a/codegen/manual_server.cpp +++ b/codegen/manual_server.cpp @@ -596,3 +596,56 @@ int handle___cudaRegisterVar(void *conn) return 0; } + +int handle_cudaFree(void *conn) +{ + void* devPtr; + int request_id; + cudaError_t scuda_intercept_result; + if ( + rpc_read(conn, &devPtr, sizeof(void*)) < 0 || + false) + goto ERROR_0; + + request_id = rpc_end_request(conn); + if (request_id < 0) + goto ERROR_0; + scuda_intercept_result = cudaFree(devPtr); + + if (rpc_start_response(conn, request_id) < 0 || + rpc_end_response(conn, &scuda_intercept_result) < 0) + goto ERROR_0; + + return 0; +ERROR_0: + return -1; +} + +int handle_cudaMallocManaged(void *conn) +{ + void* devPtr; + size_t size; + unsigned int flags; + int request_id; + cudaError_t scuda_intercept_result; + if ( + rpc_read(conn, &devPtr, sizeof(void*)) < 0 || + rpc_read(conn, &size, sizeof(size_t)) < 0 || + rpc_read(conn, &flags, sizeof(unsigned int)) < 0 || + false) + goto ERROR_0; + + request_id = rpc_end_request(conn); + if (request_id < 0) + goto ERROR_0; + scuda_intercept_result = cudaMallocManaged(&devPtr, size, flags); + + if (rpc_start_response(conn, request_id) < 0 || + rpc_write(conn, &devPtr, sizeof(void*)) < 0 || + rpc_end_response(conn, &scuda_intercept_result) < 0) + goto ERROR_0; + + return 0; +ERROR_0: + return -1; +} diff --git a/codegen/manual_server.h b/codegen/manual_server.h index 11e4f11..4449dea 100644 --- a/codegen/manual_server.h +++ b/codegen/manual_server.h @@ -2,9 +2,11 @@ #include #include +int handle_cudaFree(void *conn); int handle_cudaMemcpy(void *conn); int handle_cudaMemcpyAsync(void *conn); int handle_cudaLaunchKernel(void *conn); +int handle_cudaMallocManaged(void *conn); int handle___cudaRegisterVar(void *conn); int handle___cudaRegisterFunction(void *conn); int handle___cudaRegisterFatBinary(void *conn);