Skip to content

Commit

Permalink
[libc] Move RPC opcodes include out of the header
Browse files Browse the repository at this point in the history
Summary:
This header isn't strictly necessary, and is currently broken because we
install these to separate locations.
  • Loading branch information
jhuber6 committed Mar 10, 2024
1 parent a066f71 commit 8a79003
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions libc/utils/gpu/loader/Loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "utils/gpu/server/llvmlibc_rpc_server.h"

#include "llvm-libc-types/rpc_opcodes_t.h"
#include "include/llvm-libc-types/test_rpc_opcodes_t.h"

#include <cstddef>
Expand Down
4 changes: 4 additions & 0 deletions libc/utils/gpu/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ endif()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/llvmlibc_rpc_server.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT libc-headers)
install(FILES ${LIBC_SOURCE_DIR}/include/llvm-libc-types/rpc_opcodes_t.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
RENAME llvmlibc_rpc_opcodes.h
COMPONENT libc-headers)
install(TARGETS llvmlibc_rpc_server
ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}"
COMPONENT libc)
4 changes: 1 addition & 3 deletions libc/utils/gpu/server/llvmlibc_rpc_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

#include <stdint.h>

#include "llvm-libc-types/rpc_opcodes_t.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -84,7 +82,7 @@ rpc_status_t rpc_handle_server(uint32_t device_id);
/// Register a callback to handle an opcode from the RPC client. The associated
/// data must remain accessible as long as the user intends to handle the server
/// with this callback.
rpc_status_t rpc_register_callback(uint32_t device_id, rpc_opcode_t opcode,
rpc_status_t rpc_register_callback(uint32_t device_id, uint16_t opcode,
rpc_opcode_callback_ty callback, void *data);

/// Obtain a pointer to a local client buffer that can be copied directly to the
Expand Down
10 changes: 5 additions & 5 deletions libc/utils/gpu/server/rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ static_assert(RPC_MAXIMUM_PORT_COUNT == rpc::MAX_PORT_COUNT,
template <uint32_t lane_size>
rpc_status_t handle_server_impl(
rpc::Server &server,
const std::unordered_map<rpc_opcode_t, rpc_opcode_callback_ty> &callbacks,
const std::unordered_map<rpc_opcode_t, void *> &callback_data,
const std::unordered_map<uint16_t, rpc_opcode_callback_ty> &callbacks,
const std::unordered_map<uint16_t, void *> &callback_data,
uint32_t &index) {
auto port = server.try_open(lane_size, index);
if (!port)
Expand Down Expand Up @@ -239,8 +239,8 @@ struct Device {
void *buffer;
rpc::Server server;
rpc::Client client;
std::unordered_map<rpc_opcode_t, rpc_opcode_callback_ty> callbacks;
std::unordered_map<rpc_opcode_t, void *> callback_data;
std::unordered_map<uint16_t, rpc_opcode_callback_ty> callbacks;
std::unordered_map<uint16_t, void *> callback_data;
};

// A struct containing all the runtime state required to run the RPC server.
Expand Down Expand Up @@ -335,7 +335,7 @@ rpc_status_t rpc_handle_server(uint32_t device_id) {
}
}

rpc_status_t rpc_register_callback(uint32_t device_id, rpc_opcode_t opcode,
rpc_status_t rpc_register_callback(uint32_t device_id, uint16_t opcode,
rpc_opcode_callback_ty callback,
void *data) {
if (!state)
Expand Down
1 change: 1 addition & 0 deletions openmp/libomptarget/plugins-nextgen/common/src/RPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "PluginInterface.h"

#if defined(LIBOMPTARGET_RPC_SUPPORT)
#include "llvm-libc-types/rpc_opcodes_t.h"
#include "llvmlibc_rpc_server.h"
#endif

Expand Down

0 comments on commit 8a79003

Please sign in to comment.