Legate.jl
Loading...
Searching...
No Matches
wrapper.inl
Go to the documentation of this file.
1/* Copyright 2025 Northwestern University,
2 * Carnegie Mellon University University
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * Author(s): David Krasowska <krasow@u.northwestern.edu>
17 * Ethan Meitz <emeitz@andrew.cmu.edu>
18 */
19
20#include "legate.h"
21#include "legate/mapping/machine.h"
22#include "legate/runtime/runtime.h"
23#include "legate/timing/timing.h"
24#include "legion.h"
25#include "legion/legion_config.h"
26
27using namespace legate;
34namespace legate_wrapper {
35namespace runtime {
36
41inline void start_legate() { legate::start(); }
42
47inline int32_t legate_finish() { return legate::finish(); }
48
53inline Runtime* get_runtime() { return Runtime::get_runtime(); }
54
59inline bool has_started() { return legate::has_started(); }
60
65inline bool has_finished() { return legate::has_finished(); }
66} // namespace runtime
67
68namespace tasking {
75inline Constraint align(const Variable& a, const Variable& b) {
76 return legate::align(a, b);
77}
78
88inline AutoTask create_auto_task(Runtime* rt, Library lib, LocalTaskID id) {
89 return rt->create_task(lib, id);
90}
91
102inline ManualTask create_manual_task(Runtime* rt, Library lib, LocalTaskID id,
103 const Domain& domain) {
104 return rt->create_task(lib, id, domain);
105}
106
114inline auto submit_auto_task(Runtime* rt, AutoTask& task) {
115 return rt->submit(std::move(task));
116}
117
125inline auto submit_manual_task(Runtime* rt, ManualTask& task) {
126 return rt->submit(std::move(task));
127}
128
129} // namespace tasking
130
131namespace data {
138inline Scalar string_to_scalar(std::string str) { return Scalar(str); }
139
148inline LogicalArray create_unbound_array(const Type& ty, std::uint32_t dim = 1,
149 bool nullable = false) {
150 return Runtime::get_runtime()->create_array(ty, dim, nullable);
151}
152
162inline LogicalArray create_array(const Shape& shape, const Type& ty,
163 bool nullable = false,
164 bool optimize_scalar = false) {
165 return Runtime::get_runtime()->create_array(shape, ty, nullable,
166 optimize_scalar);
167}
168
176inline LogicalStore create_unbound_store(const Type& ty,
177 std::uint32_t dim = 1) {
178 return Runtime::get_runtime()->create_store(ty, dim);
179}
180
189inline LogicalStore create_store(const Shape& shape, const Type& ty,
190 bool optimize_scalar = false) {
191 return Runtime::get_runtime()->create_store(shape, ty, optimize_scalar);
192}
193
201inline LogicalStore store_from_scalar(const Scalar& scalar,
202 const Shape& shape = Shape{1}) {
203 return Runtime::get_runtime()->create_store(scalar, shape);
204}
205} // namespace data
206
207namespace time {
208
213inline uint64_t time_microseconds() {
214 return legate::timing::measure_microseconds().value();
215}
216
221inline uint64_t time_nanoseconds() {
222 return legate::timing::measure_nanoseconds().value();
223}
224} // namespace time
225} // namespace legate_wrapper
Definition wrapper.inl:131
Scalar string_to_scalar(std::string str)
Convert a string to a Scalar.
Definition wrapper.inl:138
LogicalArray create_unbound_array(const Type &ty, std::uint32_t dim=1, bool nullable=false)
Create an unbound array.
Definition wrapper.inl:148
LogicalStore store_from_scalar(const Scalar &scalar, const Shape &shape=Shape{1})
Create a store from a scalar value.
Definition wrapper.inl:201
LogicalArray create_array(const Shape &shape, const Type &ty, bool nullable=false, bool optimize_scalar=false)
Create an array with a specified shape.
Definition wrapper.inl:162
LogicalStore create_store(const Shape &shape, const Type &ty, bool optimize_scalar=false)
Create a store with a specified shape.
Definition wrapper.inl:189
LogicalStore create_unbound_store(const Type &ty, std::uint32_t dim=1)
Create an unbound store.
Definition wrapper.inl:176
Definition wrapper.inl:35
int32_t legate_finish()
Finalize the Legate runtime.
Definition wrapper.inl:47
bool has_started()
Check whether the Legate runtime has started.
Definition wrapper.inl:59
void start_legate()
Start the Legate runtime.
Definition wrapper.inl:41
bool has_finished()
Check whether the Legate runtime has finished.
Definition wrapper.inl:65
Runtime * get_runtime()
Return the current Legate runtime instance.
Definition wrapper.inl:53
Definition wrapper.inl:68
auto submit_manual_task(Runtime *rt, ManualTask &task)
Submit a manual task to the runtime.
Definition wrapper.inl:125
auto submit_auto_task(Runtime *rt, AutoTask &task)
Submit an auto task to the runtime.
Definition wrapper.inl:114
Constraint align(const Variable &a, const Variable &b)
Align two variables.
Definition wrapper.inl:75
ManualTask create_manual_task(Runtime *rt, Library lib, LocalTaskID id, const Domain &domain)
Create an manual task in the runtime.
Definition wrapper.inl:102
AutoTask create_auto_task(Runtime *rt, Library lib, LocalTaskID id)
Create an auto task in the runtime.
Definition wrapper.inl:88
Definition wrapper.inl:207
uint64_t time_nanoseconds()
Measure time in nanoseconds.
Definition wrapper.inl:221
uint64_t time_microseconds()
Measure time in microseconds.
Definition wrapper.inl:213
These functions can be invoked from Julia.
Definition wrapper.inl:34