forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core]create internal module for thridparty system compatible building (
- Loading branch information
Showing
4 changed files
with
210 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Copyright 2020 The Ray Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "ray/internal/internal.h" | ||
|
||
#include "ray/core_worker/core_worker.h" | ||
|
||
namespace ray { | ||
namespace internal { | ||
// NOTE(lingxuan.zlx): This internal module is designed to export ray symbols | ||
// to other thirdparty outside project, which makes they can access internal | ||
// function of core worker library or native function and reduce symbols racing. | ||
|
||
using ray::core::CoreWorkerProcess; | ||
using ray::core::TaskOptions; | ||
|
||
std::vector<rpc::ObjectReference> SendInternal( | ||
const ActorID &peer_actor_id, | ||
std::shared_ptr<LocalMemoryBuffer> buffer, | ||
RayFunction &function, | ||
int return_num, | ||
int max_retries, | ||
bool retry_exceptions, | ||
std::string serialized_retry_exception_allowlist) { | ||
std::unordered_map<std::string, double> resources; | ||
std::string name = function.GetFunctionDescriptor()->DefaultTaskName(); | ||
TaskOptions options{name, return_num, resources}; | ||
|
||
char meta_data[3] = {'R', 'A', 'W'}; | ||
std::shared_ptr<LocalMemoryBuffer> meta = | ||
std::make_shared<LocalMemoryBuffer>((uint8_t *)meta_data, 3, true); | ||
|
||
std::vector<std::unique_ptr<TaskArg>> args; | ||
if (function.GetLanguage() == Language::PYTHON) { | ||
auto dummy = "__RAY_DUMMY__"; | ||
std::shared_ptr<LocalMemoryBuffer> dummyBuffer = | ||
std::make_shared<LocalMemoryBuffer>((uint8_t *)dummy, 13, true); | ||
args.emplace_back(new TaskArgByValue(std::make_shared<RayObject>( | ||
std::move(dummyBuffer), meta, std::vector<rpc::ObjectReference>(), true))); | ||
} | ||
args.emplace_back(new TaskArgByValue(std::make_shared<RayObject>( | ||
std::move(buffer), meta, std::vector<rpc::ObjectReference>(), true))); | ||
|
||
std::vector<std::shared_ptr<RayObject>> results; | ||
std::vector<rpc::ObjectReference> return_refs; | ||
auto result = CoreWorkerProcess::GetCoreWorker().SubmitActorTask( | ||
peer_actor_id, | ||
function, | ||
args, | ||
options, | ||
max_retries, | ||
retry_exceptions, | ||
serialized_retry_exception_allowlist, | ||
return_refs); | ||
if (!result.ok()) { | ||
RAY_CHECK(false) << "Back pressure should not be enabled."; | ||
} | ||
return return_refs; | ||
} | ||
|
||
const ray::stats::TagKeyType TagRegister(const std::string tag_name) { | ||
return ray::stats::TagKeyType::Register(tag_name); | ||
} | ||
|
||
const std::string TagKeyName(stats::TagKeyType &tagkey) { return tagkey.name(); } | ||
|
||
const ActorID &GetCurrentActorID() { | ||
return CoreWorkerProcess::GetCoreWorker().GetWorkerContext().GetCurrentActorID(); | ||
} | ||
|
||
bool IsInitialized() { return CoreWorkerProcess::IsInitialized(); } | ||
|
||
} // namespace internal | ||
} // namespace ray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2020 The Ray Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
#include "ray/common/buffer.h" | ||
#include "ray/common/id.h" | ||
#include "ray/core_worker/common.h" | ||
#include "ray/stats/metric.h" | ||
|
||
// This header is used to warp some internal code so we can reduce suspicious | ||
// symbols export. | ||
namespace ray { | ||
namespace internal { | ||
|
||
using ray::core::RayFunction; | ||
|
||
/// Send buffer internal | ||
/// \param[in] buffer buffer to be sent. | ||
/// \param[in] function the function descriptor of peer's function. | ||
/// \param[in] return_num return value number of the call. | ||
/// \param[in] max_retirs task retries time. | ||
/// \param[in] retry_execptions whether retry if execptions found. | ||
/// \param[in] serialized_retry_exception_allowlist specificed allowed exceptions. | ||
/// \param[out] return_ids return ids from SubmitActorTask. | ||
std::vector<rpc::ObjectReference> SendInternal( | ||
const ActorID &peer_actor_id, | ||
std::shared_ptr<LocalMemoryBuffer> buffer, | ||
RayFunction &function, | ||
int return_num, | ||
int max_retries = -1, | ||
bool retry_exceptions = false, | ||
std::string serialized_retry_exception_allowlist = ""); | ||
|
||
const stats::TagKeyType TagRegister(const std::string tag_name); | ||
|
||
const std::string TagKeyName(stats::TagKeyType &tagkey); | ||
|
||
/// Get current actor id via internal. | ||
const ActorID &GetCurrentActorID(); | ||
|
||
/// Get core worker initialization flag via internal. | ||
bool IsInitialized(); | ||
} // namespace internal | ||
} // namespace ray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,5 @@ | |
*PyInit__raylet* | ||
*Java_io_ray* | ||
_JNI_On* | ||
*aligned_free* | ||
*aligned_malloc* |