-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc] Move libc server handlers to a shared header #117908
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,10 +32,7 @@ elseif(${LIBOMPTARGET_GPU_LIBC_SUPPORT}) | |
| target_link_libraries(PluginCommon PRIVATE ${llvmlibc_rpc_server}) | ||
| target_compile_definitions(PluginCommon PRIVATE LIBOMPTARGET_RPC_SUPPORT) | ||
| # We may need to get the headers directly from the 'libc' source directory. | ||
| target_include_directories(PluginCommon PRIVATE | ||
| ${CMAKE_SOURCE_DIR}/../libc/utils/gpu/server | ||
| ${CMAKE_SOURCE_DIR}/../libc/ | ||
| ${CMAKE_SOURCE_DIR}/../libc/include) | ||
| target_include_directories(PluginCommon PRIVATE ${CMAKE_SOURCE_DIR}/../libc/) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is fine, but I wonder why don't we just export libc's rpc as a target and then just link against the target, such that CMake will handle all the interface directories.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You just described the next patch I'm going to do once this lands. We already have something called |
||
| endif() | ||
| endif() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ | |
|
|
||
| // TODO: This should be included unconditionally and cleaned up. | ||
| #if defined(LIBOMPTARGET_RPC_SUPPORT) | ||
| #include "llvmlibc_rpc_server.h" | ||
| #include "shared/rpc.h" | ||
| #include "shared/rpc_opcodes.h" | ||
| #endif | ||
|
|
@@ -79,32 +78,32 @@ Error RPCServerTy::runServer(plugin::GenericDeviceTy &Device) { | |
| std::min(Device.requestedRPCPortCount(), rpc::MAX_PORT_COUNT); | ||
| rpc::Server Server(NumPorts, Buffers[Device.getDeviceId()]); | ||
|
|
||
| auto port = Server.try_open(Device.getWarpSize()); | ||
| if (!port) | ||
| auto Port = Server.try_open(Device.getWarpSize()); | ||
| if (!Port) | ||
| return Error::success(); | ||
|
|
||
| int Status = rpc::SUCCESS; | ||
| switch (port->get_opcode()) { | ||
| switch (Port->get_opcode()) { | ||
| case RPC_MALLOC: { | ||
| port->recv_and_send([&](rpc::Buffer *Buffer, uint32_t) { | ||
| Port->recv_and_send([&](rpc::Buffer *Buffer, uint32_t) { | ||
| Buffer->data[0] = reinterpret_cast<uintptr_t>(Device.allocate( | ||
| Buffer->data[0], nullptr, TARGET_ALLOC_DEVICE_NON_BLOCKING)); | ||
| }); | ||
| break; | ||
| } | ||
| case RPC_FREE: { | ||
| port->recv([&](rpc::Buffer *Buffer, uint32_t) { | ||
| Port->recv([&](rpc::Buffer *Buffer, uint32_t) { | ||
| Device.free(reinterpret_cast<void *>(Buffer->data[0]), | ||
| TARGET_ALLOC_DEVICE_NON_BLOCKING); | ||
| }); | ||
| break; | ||
| } | ||
| default: | ||
| // Let the `libc` library handle any other unhandled opcodes. | ||
| Status = libc_handle_rpc_port(&*port, Device.getWarpSize()); | ||
| Status = handle_libc_opcodes(*Port, Device.getWarpSize()); | ||
| break; | ||
| } | ||
| port->close(); | ||
| Port->close(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
NVM. This is |
||
|
|
||
| if (Status != rpc::SUCCESS) | ||
| return createStringError("RPC server given invalid opcode!"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it confusing looking at the variable name of libc project. what is the rule here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is code that
libcexports to handle the opcodesoffloaddoesn't know how to handle.