chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:17:40 +08:00
commit f1825c8ceb
10096 changed files with 2364182 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
build --cxxopt="-std=c++17"
build --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
+43
View File
@@ -0,0 +1,43 @@
"""BUILD rules for Ray C++ examples."""
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
cc_binary(
name = "example",
srcs = glob([
"*.cc",
]),
data = [
"example.so",
],
linkstatic = True,
deps = [
":ray_api",
],
)
cc_binary(
name = "example.so",
srcs = glob([
"*.cc",
]),
linkopts = ["-shared"],
linkstatic = True,
deps = [
":ray_api",
],
)
cc_library(
name = "ray_api",
srcs = [
"thirdparty/lib/libray_api.so",
],
hdrs = glob([
"thirdparty/include/**/*.h",
"thirdparty/include/**/*.hpp",
]),
linkopts = ["-Wl,-rpath,./"],
strip_include_prefix = "thirdparty/include",
visibility = ["//visibility:public"],
)
View File
+59
View File
@@ -0,0 +1,59 @@
/// This is an example of Ray C++ application. Please visit
/// `https://docs.ray.io/en/master/ray-core/walkthrough.html#installation`
/// for more details.
/// including the `<ray/api.h>` header
#include <ray/api.h>
/// common function
int Plus(int x, int y) { return x + y; }
/// Declare remote function
RAY_REMOTE(Plus);
/// class
class Counter {
public:
int count;
Counter(int init) { count = init; }
/// static factory method
static Counter *FactoryCreate(int init) { return new Counter(init); }
/// non static function
int Add(int x) {
count += x;
return count;
}
};
/// Declare remote function
RAY_REMOTE(Counter::FactoryCreate, &Counter::Add);
int main(int argc, char **argv) {
/// initialization
ray::Init();
/// put and get object
auto object = ray::Put(100);
auto put_get_result = *(ray::Get(object));
std::cout << "put_get_result = " << put_get_result << std::endl;
/// common task
auto task_object = ray::Task(Plus).Remote(1, 2);
int task_result = *(ray::Get(task_object));
std::cout << "task_result = " << task_result << std::endl;
/// actor
ray::ActorHandle<Counter> actor = ray::Actor(Counter::FactoryCreate).Remote(0);
/// actor task
auto actor_object = actor.Task(&Counter::Add).Remote(3);
int actor_task_result = *(ray::Get(actor_object));
std::cout << "actor_task_result = " << actor_task_result << std::endl;
/// actor task with reference argument
auto actor_object2 = actor.Task(&Counter::Add).Remote(task_object);
int actor_task_result2 = *(ray::Get(actor_object2));
std::cout << "actor_task_result2 = " << actor_task_result2 << std::endl;
/// shutdown
ray::Shutdown();
return 0;
}
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
#Cause the script to exit if a single command fails.
set -e
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE:-$0}")" || exit; pwd)"
bazel --nosystem_rc --nohome_rc build //:example
if [[ "$OSTYPE" == "darwin"* ]]; then
DYLD_LIBRARY_PATH="$ROOT_DIR/thirdparty/lib" "${ROOT_DIR}"/bazel-bin/example
else
LD_LIBRARY_PATH="$ROOT_DIR/thirdparty/lib" "${ROOT_DIR}"/bazel-bin/example
fi