Skip to content
Open
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
4 changes: 4 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
[(#3031)](https://github.com/PennyLaneAI/catalyst/pull/3031)
[(#3030)](https://github.com/PennyLaneAI/catalyst/pull/3030)

- The `catalyst-executor` server side is now added to Catalyst that receives objects, maps them
and calls them.
[(#3088)](https://github.com/PennyLaneAI/catalyst/pull/3088)

* A `BufferizableOpInterface` implementation is now added for `catalyst.launch_kernel` operation and it is now bufferizable.
[(#3024)](https://github.com/PennyLaneAI/catalyst/pull/3024)

Expand Down
2 changes: 1 addition & 1 deletion runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ifeq ($(ENABLE_TRANSPORT), ON)
endif

ifeq ($(ENABLE_EXECUTOR), ON)
BUILD_TARGETS += rt_executor
BUILD_TARGETS += rt_executor catalyst-executor
endif

.PHONY: help
Expand Down
32 changes: 31 additions & 1 deletion runtime/lib/executor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
###############################################
# library catalyst_executor_session + rt_executor #
# catalyst_executor_session + rt_executor + catalyst-executor
# HOST rt_executor the C ABI a compiled program calls, over handles
# catalyst_executor_session the ORC client it drives
# NODE catalyst-executor the ORC server: receives objects, maps them, calls them
###############################################

find_package(LLVM CONFIG REQUIRED)
Expand Down Expand Up @@ -61,3 +64,30 @@ if(NOT APPLE)
else()
set_property(TARGET rt_executor APPEND PROPERTY BUILD_RPATH @loader_path)
endif()

# catalyst-executor

llvm_map_components_to_libnames(_executor_bin_llvm_libs
orcjit orctargetprocess orcshared support
)

add_executable(catalyst-executor executor.cpp)

target_include_directories(catalyst-executor SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS})

target_link_libraries(catalyst-executor PRIVATE
${_executor_bin_llvm_libs}
pthread
${CMAKE_DL_LIBS}
)

target_compile_options(catalyst-executor PRIVATE -fno-rtti)

if(APPLE)
target_link_options(catalyst-executor PRIVATE -Wl,-export_dynamic)
else()
target_link_options(catalyst-executor PRIVATE -Wl,--export-dynamic)
endif()

set_target_properties(catalyst-executor PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
18 changes: 13 additions & 5 deletions runtime/lib/executor/ExecutorSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ Expected<std::unique_ptr<MemoryBuffer>> getFile(const Twine &filename)
return createFileError(filename, F.getError());
}

void discardEPC(Expected<std::unique_ptr<SimpleRemoteEPC>> &EPC)
{
consumeError(EPC ? (*EPC)->disconnect() : EPC.takeError());
}

} // namespace

namespace catalyst::executor {
Expand Down Expand Up @@ -346,10 +351,7 @@ struct ExecutorSession {
}

if (timedOut) {
// Consume any error the forced socket shutdown produced before reporting the timeout.
if (!EPC) {
consumeError(EPC.takeError());
}
discardEPC(EPC);
return createTCPSocketError("handshake with catalyst-executor timed out after " +
Twine(timeoutSecs) +
"s (is a catalyst-executor actually listening there?). "
Expand All @@ -362,7 +364,13 @@ struct ExecutorSession {
JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple());
auto DL = JTMB.getDefaultDataLayoutForTarget();
if (!DL) {
return DL.takeError();
discardEPC(EPC);
return joinErrors(
createStringError(llvm::inconvertibleErrorCode(),
"no data layout for the catalyst-executor's target triple '" +
(*EPC)->getTargetTriple().str() +
"'; this runtime may lack the LLVM backend for it"),
DL.takeError());
}

auto ES = std::make_unique<ExecutionSession>(std::move(*EPC));
Expand Down
Loading
Loading