21#include "legate/mapping/machine.h"
22#include "legate/runtime/runtime.h"
23#include "legate/timing/timing.h"
25#include "legion/legion_config.h"
27using namespace legate;
53inline Runtime*
get_runtime() {
return Runtime::get_runtime(); }
75inline Constraint
align(
const Variable& a,
const Variable& b) {
76 return legate::align(a, b);
89 return rt->create_task(lib,
id);
103 const Domain& domain) {
104 return rt->create_task(lib,
id, domain);
115 if (shape.volume() == 0)
return Domain::NO_DOMAIN;
116 switch (shape.ndim()) {
118 Legion::Point<1> lo = Legion::Point<1>::ZEROES();
120 hi[0] = shape[0] - 1;
121 return Domain(Legion::Rect<1>(lo, hi));
124 Legion::Point<2> lo = Legion::Point<2>::ZEROES();
126 hi[0] = shape[0] - 1;
127 hi[1] = shape[1] - 1;
128 return Domain(Legion::Rect<2>(lo, hi));
131 Legion::Point<3> lo = Legion::Point<3>::ZEROES();
133 hi[0] = shape[0] - 1;
134 hi[1] = shape[1] - 1;
135 hi[2] = shape[2] - 1;
136 return Domain(Legion::Rect<3>(lo, hi));
139 return Domain::NO_DOMAIN;
151 return rt->submit(std::move(task));
162 return rt->submit(std::move(task));
185 bool nullable =
false) {
186 return Runtime::get_runtime()->create_array(ty, dim, nullable);
199 bool nullable =
false,
200 bool optimize_scalar =
false) {
201 return Runtime::get_runtime()->create_array(shape, ty, nullable,
213 std::uint32_t dim = 1) {
214 return Runtime::get_runtime()->create_store(ty, dim);
226 bool optimize_scalar =
false) {
227 return Runtime::get_runtime()->create_store(shape, ty, optimize_scalar);
238 const Shape& shape = Shape{1}) {
239 return Runtime::get_runtime()->create_store(scalar, shape);
252 legate::ExternalAllocation alloc = legate::ExternalAllocation::create_sysmem(
253 ptr, shape.volume() * ty.size());
254 legate::mapping::DimOrdering ordering =
255 legate::mapping::DimOrdering::fortran_order();
258 legate::Runtime::get_runtime()->create_store(shape, ty, alloc, ordering);
274 const Type& ty,
bool readonly) {
275 legate::ExternalAllocation alloc = legate::ExternalAllocation::create_fbmem(
276 device_id, ptr, shape.volume() * ty.size(), readonly);
277 legate::mapping::DimOrdering ordering =
278 legate::mapping::DimOrdering::fortran_order();
281 legate::Runtime::get_runtime()->create_store(shape, ty, alloc, ordering);
286 template <legate::Type::Code CODE,
int DIM>
288#if !LEGATE_DEFINED(LEGATE_USE_CUDA)
290 if (CODE == legate::Type::Code::FLOAT16) {
291 throw std::runtime_error(
292 "FLOAT16 type is not supported when building without CUDA");
296 auto shp = store->shape<DIM>();
297 return store->write_accessor<CppT, DIM>().ptr(Realm::Point<DIM>(shp.lo));
307inline void*
get_ptr(legate::PhysicalStore* store) {
308 int dim = store->dim();
309 legate::Type::Code
code = store->type().code();
322 return legate::timing::measure_microseconds().value();
330 return legate::timing::measure_nanoseconds().value();
Definition wrapper.inl:167
Scalar string_to_scalar(std::string str)
Convert a string to a Scalar.
Definition wrapper.inl:174
LogicalArray create_unbound_array(const Type &ty, std::uint32_t dim=1, bool nullable=false)
Create an unbound array.
Definition wrapper.inl:184
LogicalStore store_from_scalar(const Scalar &scalar, const Shape &shape=Shape{1})
Create a store from a scalar value.
Definition wrapper.inl:237
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:198
LogicalStore create_store(const Shape &shape, const Type &ty, bool optimize_scalar=false)
Create a store with a specified shape.
Definition wrapper.inl:225
LogicalStore attach_external_store_fbmem(int device_id, void *ptr, const Shape &shape, const Type &ty, bool readonly)
Attach an external store in frame buffer memory.
Definition wrapper.inl:272
void * get_ptr(legate::PhysicalStore *store)
Get a pointer to the data in a PhysicalStore.
Definition wrapper.inl:307
LogicalStore attach_external_store_sysmem(void *ptr, const Shape &shape, const Type &ty)
Attach an external store in system memory.
Definition wrapper.inl:250
LogicalStore create_unbound_store(const Type &ty, std::uint32_t dim=1)
Create an unbound store.
Definition wrapper.inl:212
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:161
Domain domain_from_shape(const Shape &shape)
Create a Domain from a Shape.
Definition wrapper.inl:114
auto submit_auto_task(Runtime *rt, AutoTask &task)
Submit an auto task to the runtime.
Definition wrapper.inl:150
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:315
uint64_t time_nanoseconds()
Measure time in nanoseconds.
Definition wrapper.inl:329
uint64_t time_microseconds()
Measure time in microseconds.
Definition wrapper.inl:321
These functions can be invoked from Julia.
Definition wrapper.inl:34
Definition wrapper.inl:285
void * operator()(legate::PhysicalStore *store)
Definition wrapper.inl:287
std::int32_t code(legate::Type ty)
Definition types.cpp:26