Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brodey | graph #94

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
350c7d8
chore: bm
brodeynewman Oct 9, 2024
1ad672a
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Oct 9, 2024
59150ee
chore: merge
brodeynewman Oct 9, 2024
c7d0b7d
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Oct 11, 2024
29a919e
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Oct 14, 2024
233b8e9
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Oct 14, 2024
fc00189
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Oct 17, 2024
79ccd26
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Oct 23, 2024
38a351c
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Oct 29, 2024
ab2e209
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Nov 6, 2024
ccd7c31
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Nov 8, 2024
25cad41
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Nov 9, 2024
11f8e43
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Nov 11, 2024
8e3d836
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Nov 18, 2024
e20c750
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Nov 28, 2024
8f56379
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Dec 2, 2024
e5592dc
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Dec 3, 2024
aeef059
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Dec 7, 2024
83d1ebc
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Dec 16, 2024
5fb85af
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Dec 20, 2024
644f22a
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Dec 20, 2024
6190ac0
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Dec 27, 2024
f5357d8
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Jan 2, 2025
aaa8aba
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Jan 4, 2025
f2026af
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Jan 6, 2025
2e4127b
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Jan 7, 2025
9c3c589
fix: readme
brodeynewman Jan 7, 2025
acfa83a
chore: merge
brodeynewman Jan 8, 2025
5ebc31a
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Jan 8, 2025
d8e714d
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Jan 13, 2025
0d79fe5
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Jan 21, 2025
169b5f2
Merge branch 'main' of github.com:kevmo314/scuda
brodeynewman Jan 24, 2025
e8b701c
chore: graph
brodeynewman Jan 24, 2025
e33531b
chore: fix kernel node
brodeynewman Jan 28, 2025
912963b
chore: cleanup
brodeynewman Jan 28, 2025
d3783a4
chore: iter type
brodeynewman Jan 28, 2025
50dce0a
chore: segfault stuff
brodeynewman Feb 6, 2025
1d987db
chore: track ptrs
brodeynewman Feb 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ set(CLIENT_SOURCES
)

set(SERVER_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/server.cu
${CMAKE_CURRENT_SOURCE_DIR}/server.cpp
${CMAKE_CURRENT_SOURCE_DIR}/codegen/gen_server.cpp
${CMAKE_CURRENT_SOURCE_DIR}/codegen/manual_server.cpp
)
Expand Down
7 changes: 7 additions & 0 deletions client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ typedef struct {
int write_iov_count = 0;

std::unordered_map<void *, size_t> unified_devices;
std::unordered_map<cudaHostFn_t, void*> host_functions;
} conn_t;

pthread_mutex_t conn_mutex;
Expand All @@ -68,6 +69,7 @@ static void segfault(int sig, siginfo_t *info, void *unused) {
void *allocated =
mmap((void *)aligned, sz + (uintptr_t)faulting_address - aligned,
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);

if (allocated == MAP_FAILED) {
perror("Failed to allocate memory at faulting address");
_exit(1);
Expand Down Expand Up @@ -322,6 +324,11 @@ void allocate_unified_mem_pointer(const int index, void *dev_ptr, size_t size) {
conns[index].unified_devices.insert({dev_ptr, size});
}

void allocate_host_function(const int index, const struct cudaHostNodeParams* params) {
// allocate new space for pointer mapping
conns[index].host_functions.insert({params->fn, (void*)params->userData});
}

cudaError_t cuda_memcpy_unified_ptrs(const int index, cudaMemcpyKind kind) {
for (const auto &[ptr, sz] : conns[index].unified_devices) {
size_t size = reinterpret_cast<size_t>(sz);
Expand Down
98 changes: 52 additions & 46 deletions codegen/annotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -5179,6 +5179,7 @@ cudaError_t cudaMallocManaged(void **devPtr, size_t size, unsigned int flags);
*/
cudaError_t cudaMalloc(void **devPtr, size_t size);
/**
* @disabled
* @param ptr SEND_RECV
* @param size SEND_ONLY
*/
Expand Down Expand Up @@ -5941,12 +5942,14 @@ cudaError_t cudaRuntimeGetVersion(int *runtimeVersion);
* @param flags SEND_ONLY
*/
cudaError_t cudaGraphCreate(cudaGraph_t *pGraph, unsigned int flags);

/**
* @param pGraphNode SEND_RECV
* @DISABLED
* @param numDependencies SEND_ONLY
* @param pGraphNode RECV_ONLY
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param pNodeParams SEND_RECV
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param pNodeParams SEND_ONLY NULLABLE
*/
cudaError_t
cudaGraphAddKernelNode(cudaGraphNode_t *pGraphNode, cudaGraph_t graph,
Expand Down Expand Up @@ -5991,23 +5994,24 @@ cudaError_t
cudaGraphKernelNodeSetAttribute(cudaGraphNode_t hNode,
cudaLaunchAttributeID attr,
const cudaLaunchAttributeValue *value);

/**
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param pCopyParams SEND_RECV
* @param pGraphNode RECV_ONLY
* @param graph SEND_ONLY
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param pCopyParams SEND_ONLY NULLABLE
*/
cudaError_t cudaGraphAddMemcpyNode(cudaGraphNode_t *pGraphNode,
cudaGraph_t graph,
const cudaGraphNode_t *pDependencies,
size_t numDependencies,
const struct cudaMemcpy3DParms *pCopyParams);
/**
* @param numDependencies SEND_ONLY
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param symbol SEND_RECV
* @param src SEND_RECV
* @param count SEND_ONLY
Expand All @@ -6022,10 +6026,10 @@ cudaError_t cudaGraphAddMemcpyNodeToSymbol(cudaGraphNode_t *pGraphNode,
size_t count, size_t offset,
enum cudaMemcpyKind kind);
/**
* @param numDependencies SEND_ONLY
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param dst SEND_RECV
* @param symbol SEND_RECV
* @param count SEND_ONLY
Expand All @@ -6037,10 +6041,10 @@ cudaError_t cudaGraphAddMemcpyNodeFromSymbol(
const cudaGraphNode_t *pDependencies, size_t numDependencies, void *dst,
const void *symbol, size_t count, size_t offset, enum cudaMemcpyKind kind);
/**
* @param numDependencies SEND_ONLY
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param dst SEND_RECV
* @param src SEND_RECV
* @param count SEND_ONLY
Expand Down Expand Up @@ -6101,12 +6105,13 @@ cudaError_t cudaGraphMemcpyNodeSetParamsFromSymbol(cudaGraphNode_t node,
cudaError_t cudaGraphMemcpyNodeSetParams1D(cudaGraphNode_t node, void *dst,
const void *src, size_t count,
enum cudaMemcpyKind kind);

/**
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param pMemsetParams SEND_RECV
* @param pGraphNode RECV_ONLY
* @param graph SEND_ONLY
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param pMemsetParams SEND_ONLY NULLABLE
*/
cudaError_t
cudaGraphAddMemsetNode(cudaGraphNode_t *pGraphNode, cudaGraph_t graph,
Expand All @@ -6127,11 +6132,11 @@ cudaError_t
cudaGraphMemsetNodeSetParams(cudaGraphNode_t node,
const struct cudaMemsetParams *pNodeParams);
/**
* @param numDependencies SEND_ONLY
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param pNodeParams SEND_RECV
* @param pDependencies SEND_RECV ITER:numDependencies
* @param pNodeParams SEND_ONLY NULLABLE
*/
cudaError_t cudaGraphAddHostNode(cudaGraphNode_t *pGraphNode, cudaGraph_t graph,
const cudaGraphNode_t *pDependencies,
Expand All @@ -6151,11 +6156,11 @@ cudaError_t
cudaGraphHostNodeSetParams(cudaGraphNode_t node,
const struct cudaHostNodeParams *pNodeParams);
/**
* @param numDependencies SEND_ONLY
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param childGraph SEND_ONLY
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param childGraph SEND_ONLY NULLABLE
*/
cudaError_t cudaGraphAddChildGraphNode(cudaGraphNode_t *pGraphNode,
cudaGraph_t graph,
Expand All @@ -6169,21 +6174,21 @@ cudaError_t cudaGraphAddChildGraphNode(cudaGraphNode_t *pGraphNode,
cudaError_t cudaGraphChildGraphNodeGetGraph(cudaGraphNode_t node,
cudaGraph_t *pGraph);
/**
* @param numDependencies SEND_ONLY
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param pDependencies SEND_ONLY ITER:numDependencies
*/
cudaError_t cudaGraphAddEmptyNode(cudaGraphNode_t *pGraphNode,
cudaGraph_t graph,
const cudaGraphNode_t *pDependencies,
size_t numDependencies);
/**
* @param numDependencies SEND_ONLY
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param event SEND_ONLY
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param event SEND_ONLY NULLABLE
*/
cudaError_t cudaGraphAddEventRecordNode(cudaGraphNode_t *pGraphNode,
cudaGraph_t graph,
Expand All @@ -6203,11 +6208,11 @@ cudaError_t cudaGraphEventRecordNodeGetEvent(cudaGraphNode_t node,
cudaError_t cudaGraphEventRecordNodeSetEvent(cudaGraphNode_t node,
cudaEvent_t event);
/**
* @param numDependencies SEND_ONLY
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param event SEND_ONLY
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param event SEND_ONLY NULLABLE
*/
cudaError_t cudaGraphAddEventWaitNode(cudaGraphNode_t *pGraphNode,
cudaGraph_t graph,
Expand All @@ -6227,11 +6232,11 @@ cudaError_t cudaGraphEventWaitNodeGetEvent(cudaGraphNode_t node,
cudaError_t cudaGraphEventWaitNodeSetEvent(cudaGraphNode_t node,
cudaEvent_t event);
/**
* @param numDependencies SEND_ONLY
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param nodeParams SEND_RECV
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param nodeParams SEND_ONLY NULLABLE
*/
cudaError_t cudaGraphAddExternalSemaphoresSignalNode(
cudaGraphNode_t *pGraphNode, cudaGraph_t graph,
Expand All @@ -6252,11 +6257,11 @@ cudaError_t cudaGraphExternalSemaphoresSignalNodeSetParams(
cudaGraphNode_t hNode,
const struct cudaExternalSemaphoreSignalNodeParams *nodeParams);
/**
* @param numDependencies SEND_ONLY
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param nodeParams SEND_RECV
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param nodeParams SEND_ONLY NULLABLE
*/
cudaError_t cudaGraphAddExternalSemaphoresWaitNode(
cudaGraphNode_t *pGraphNode, cudaGraph_t graph,
Expand All @@ -6277,11 +6282,11 @@ cudaError_t cudaGraphExternalSemaphoresWaitNodeSetParams(
cudaGraphNode_t hNode,
const struct cudaExternalSemaphoreWaitNodeParams *nodeParams);
/**
* @param numDependencies SEND_ONLY
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param nodeParams SEND_RECV
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param nodeParams SEND_ONLY NULLABLE
*/
cudaError_t cudaGraphAddMemAllocNode(cudaGraphNode_t *pGraphNode,
cudaGraph_t graph,
Expand All @@ -6296,11 +6301,11 @@ cudaError_t
cudaGraphMemAllocNodeGetParams(cudaGraphNode_t node,
struct cudaMemAllocNodeParams *params_out);
/**
* @param numDependencies SEND_ONLY
* @param pGraphNode SEND_RECV
* @param graph SEND_ONLY
* @param pDependencies SEND_RECV
* @param numDependencies SEND_ONLY
* @param dptr SEND_RECV
* @param pDependencies SEND_ONLY ITER:numDependencies
* @param dptr SEND_ONLY
*/
cudaError_t cudaGraphAddMemFreeNode(cudaGraphNode_t *pGraphNode,
cudaGraph_t graph,
Expand Down Expand Up @@ -6351,6 +6356,7 @@ cudaError_t cudaGraphNodeFindInClone(cudaGraphNode_t *pNode,
cudaError_t cudaGraphNodeGetType(cudaGraphNode_t node,
enum cudaGraphNodeType *pType);
/**
* @disabled
* @param graph SEND_ONLY
* @param nodes SEND_RECV
* @param numNodes SEND_RECV
Expand Down Expand Up @@ -6581,8 +6587,8 @@ cudaError_t cudaGraphExecUpdate(cudaGraphExec_t hGraphExec, cudaGraph_t hGraph,
*/
cudaError_t cudaGraphUpload(cudaGraphExec_t graphExec, cudaStream_t stream);
/**
* @param graphExec SEND_ONLY
* @param stream SEND_ONLY
* @param graphExec SEND_ONLY NULLABLE
* @param stream SEND_ONLY NULLABLE
*/
cudaError_t cudaGraphLaunch(cudaGraphExec_t graphExec, cudaStream_t stream);
/**
Expand Down
Loading