Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 clang/lib/DPCT/APINames.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ ENTRY(cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags, cuOccupancyMaxActive
ENTRY(cuOccupancyMaxPotentialBlockSize, cuOccupancyMaxPotentialBlockSize, false, NO_FLAG, P4, "comment")
ENTRY(cuOccupancyMaxPotentialBlockSizeWithFlags, cuOccupancyMaxPotentialBlockSizeWithFlags, false, NO_FLAG, P4, "comment")
ENTRY(cuCtxDisablePeerAccess, cuCtxDisablePeerAccess, false, NO_FLAG, P4, "comment")
ENTRY(cuCtxEnablePeerAccess, cuCtxEnablePeerAccess, false, NO_FLAG, P4, "comment")
ENTRY(cuCtxEnablePeerAccess, cuCtxEnablePeerAccess, true, NO_FLAG, P0, "DPCT1026/DPCT1027")
ENTRY(cuDeviceCanAccessPeer, cuDeviceCanAccessPeer, true, NO_FLAG, P4, "DPCT1031")
ENTRY(cuDeviceGetP2PAttribute, cuDeviceGetP2PAttribute, false, NO_FLAG, P4, "comment")
ENTRY(cuDevicePrimaryCtxGetState, cuDevicePrimaryCtxGetState, false, NO_FLAG, P4, "comment")
Expand Down
14 changes: 14 additions & 0 deletions clang/lib/DPCT/APINamesMemory.inc
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,20 @@ CONDITIONAL_FACTORY_ENTRY(
"You can migrate the code with peer access extension by not specifying "
"-no-dpcpp-extensions=peer_access."))

CONDITIONAL_FACTORY_ENTRY(
UsePeerAccess(),
ASSIGNABLE_FACTORY(MEMBER_CALL_FACTORY_ENTRY(
"cuCtxEnablePeerAccess",
CALL(MapNames::getDpctNamespace() + "get_current_device"), false,
"ext_oneapi_enable_peer_access",
MEMBER_CALL(CALL(MapNames::getDpctNamespace() + "dev_mgr::instance"), false,
"get_device", ARG_WC(0)))),
REMOVE_API_FACTORY_ENTRY_WITH_MSG(
"cuCtxEnablePeerAccess",
"SYCL currently does not support memory access across peer devices. "
"You can migrate the code with peer access extension by not specifying "
"-no-dpcpp-extensions=peer_access."))

CALL_FACTORY_ENTRY(
"make_cudaExtent",
CALL(DpctGlobalInfo::getCtadClass(MapNames::getClNamespace() + "range", 3),
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/DPCT/ASTTraversal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6243,7 +6243,7 @@ void FunctionCallRule::registerMatcher(MatchFinder &MF) {
"cudaPointerGetAttributes", "cuCtxSetCacheConfig", "cuCtxSetLimit",
"cudaCtxResetPersistingL2Cache", "cuCtxResetPersistingL2Cache",
"cudaStreamSetAttribute", "cudaStreamGetAttribute", "cudaProfilerStart",
"cudaProfilerStop", "__trap");
"cudaProfilerStop", "__trap", "cuCtxEnablePeerAccess");
};

MF.addMatcher(
Expand Down
4 changes: 4 additions & 0 deletions clang/test/dpct/disable-all-extensions.cu
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ int peer_access() {
// CHECK: DPCT1026:{{[0-9]+}}: The call to cudaDeviceDisablePeerAccess was removed because SYCL currently does not support memory access across peer devices. You can migrate the code with peer access extension by not specifying -no-dpcpp-extensions=peer_access.
// CHECK: */
cudaDeviceDisablePeerAccess(0);
// CHECK: /*
// CHECK: DPCT1026:{{[0-9]+}}: The call to cuCtxEnablePeerAccess was removed because SYCL currently does not support memory access across peer devices. You can migrate the code with peer access extension by not specifying -no-dpcpp-extensions=peer_access.
// CHECK: */
cuCtxEnablePeerAccess(0, 0);

return 0;
}
Expand Down
3 changes: 3 additions & 0 deletions clang/test/dpct/driver_context.cu
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ int main(){
// CHECK: MY_SAFE_CALL(DPCT_CHECK_ERROR(dpct::select_device(ctx)));
MY_SAFE_CALL(cuCtxSetCurrent(ctx));

// CHECK: dpct::get_current_device().ext_oneapi_enable_peer_access(dpct::dev_mgr::instance().get_device(ctx2));
cuCtxEnablePeerAccess(ctx2, 0);

// CHECK: ctx2 = dpct::dev_mgr::instance().current_device_id();
cuCtxGetCurrent(&ctx2);

Expand Down