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.
Convert task_spec to flatbuffers (ray-project#255)
* convert Ray to C++ * convert task_spec to flatbuffers * fix * it compiles * latest * tests are passing * task2 -> task * fix * fix * fix * fix * fix * linting * fix valgrind * upgrade flatbuffers * use debug mode for valgrind * fix naming and comments * downgrade flatbuffers * fix linting * reintroduce TaskSpec_free * rename TaskSpec -> TaskInfo * refactoring * linting
- Loading branch information
1 parent
65a8659
commit 0b8d279
Showing
36 changed files
with
1,052 additions
and
929 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
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,26 @@ | ||
#include "common_protocol.h" | ||
|
||
flatbuffers::Offset<flatbuffers::String> to_flatbuf( | ||
flatbuffers::FlatBufferBuilder &fbb, | ||
ObjectID object_id) { | ||
return fbb.CreateString((char *) &object_id.id[0], sizeof(object_id.id)); | ||
} | ||
|
||
ObjectID from_flatbuf(const flatbuffers::String *string) { | ||
ObjectID object_id; | ||
CHECK(string->size() == sizeof(object_id.id)); | ||
memcpy(&object_id.id[0], string->data(), sizeof(object_id.id)); | ||
return object_id; | ||
} | ||
|
||
flatbuffers::Offset< | ||
flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> | ||
to_flatbuf(flatbuffers::FlatBufferBuilder &fbb, | ||
ObjectID object_ids[], | ||
int64_t num_objects) { | ||
std::vector<flatbuffers::Offset<flatbuffers::String>> results; | ||
for (size_t i = 0; i < num_objects; i++) { | ||
results.push_back(to_flatbuf(fbb, object_ids[i])); | ||
} | ||
return fbb.CreateVector(results); | ||
} |
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,41 @@ | ||
#ifndef COMMON_PROTOCOL_H | ||
#define COMMON_PROTOCOL_H | ||
|
||
#include "format/common_generated.h" | ||
|
||
#include "common.h" | ||
|
||
/** | ||
* Convert an object ID to a flatbuffer string. | ||
* | ||
* @param fbb Reference to the flatbuffer builder. | ||
* @param object_id The object ID to be converted. | ||
* @return The flatbuffer string contining the object ID. | ||
*/ | ||
flatbuffers::Offset<flatbuffers::String> to_flatbuf( | ||
flatbuffers::FlatBufferBuilder &fbb, | ||
ObjectID object_id); | ||
|
||
/** | ||
* Convert a flatbuffer string to an object ID. | ||
* | ||
* @param string The flatbuffer string. | ||
* @return The object ID. | ||
*/ | ||
ObjectID from_flatbuf(const flatbuffers::String *string); | ||
|
||
/** | ||
* Convert an array of object IDs to a flatbuffer vector of strings. | ||
* | ||
* @param fbb Reference to the flatbuffer builder. | ||
* @param object_ids Array of object IDs. | ||
* @param num_objects Number of elements in the array. | ||
* @return Flatbuffer vector of strings. | ||
*/ | ||
flatbuffers::Offset< | ||
flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> | ||
to_flatbuf(flatbuffers::FlatBufferBuilder &fbb, | ||
ObjectID object_ids[], | ||
int64_t num_objects); | ||
|
||
#endif |
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,52 @@ | ||
|
||
// Indices into resource vectors. | ||
// A resource vector maps a resource index to the number | ||
// of units of that resource required. | ||
|
||
// The total length of the resource vector is ResourceIndex_MAX. | ||
enum ResourceIndex:int { | ||
// A central processing unit. | ||
CPU = 0, | ||
// A graphics processing unit. | ||
GPU = 1, | ||
// A dummy entry to make ResourceIndex_MAX equal to the length of | ||
// a resource vector. | ||
DUMMY = 2 | ||
} | ||
|
||
table Arg { | ||
// Object ID for pass-by-reference arguments. | ||
object_id: string; | ||
// Data for pass-by-value arguments. | ||
data: string; | ||
} | ||
|
||
table TaskInfo { | ||
// ID of the driver that created this task. | ||
driver_id: string; | ||
// Task ID of the task. | ||
task_id: string; | ||
// Task ID of the parent task. | ||
parent_task_id: string; | ||
// A count of the number of tasks submitted by the parent task before this one. | ||
parent_counter: int; | ||
// Actor ID of the task. This is the actor that this task is executed on | ||
// or NIL_ACTOR_ID if the task is just a normal task. | ||
actor_id: string; | ||
// Number of tasks that have been submitted to this actor so far. | ||
actor_counter: int; | ||
// Function ID of the task. | ||
function_id: string; | ||
// Task arguments. | ||
args: [Arg]; | ||
// Object IDs of return values. | ||
returns: [string]; | ||
// The required_resources vector indicates the quantities of the different | ||
// resources required by this task. The index in this vector corresponds to | ||
// the resource type defined in the ResourceIndex enum. For example, | ||
// required_resources[0] is the number of CPUs required, and | ||
// required_resources[1] is the number of GPUs required. | ||
required_resources: [double]; | ||
} | ||
|
||
root_type TaskInfo; |
Oops, something went wrong.