Skip to content

Commit

Permalink
chore: manual server
Browse files Browse the repository at this point in the history
  • Loading branch information
brodeynewman committed Dec 19, 2024
1 parent a90da39 commit 2d744fd
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
53 changes: 53 additions & 0 deletions codegen/manual_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions codegen/manual_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
#include <cuda.h>
#include <cuda_runtime.h>

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);
Expand Down

0 comments on commit 2d744fd

Please sign in to comment.