Exemplo n.º 1
0
    def create_future_from_scalar(self, scalar):
        if scalar.valid:
            if ty.is_string_dtype(scalar.dtype):
                size = len(scalar._value)
                buf = struct.pack(
                    f"iiQ{size}s",
                    scalar.valid,
                    ty.encode_dtype(scalar.dtype),
                    size,
                    scalar._value.encode("utf-8"),
                )
            else:
                fmt = ty.to_format_string(scalar.dtype.storage_dtype)
                buf = struct.pack(
                    "ii" + fmt,
                    scalar.valid,
                    ty.encode_dtype(scalar.dtype),
                    scalar._value,
                )
        else:
            buf = struct.pack("iiQ", scalar.valid,
                              ty.encode_dtype(scalar.dtype), 0)

        fut = Future()
        fut.set_value(self._runtime, buf, len(buf))
        return PandasFuture(self, fut, scalar.dtype, True)
Exemplo n.º 2
0
 def _get_tunable(self, tunable_id, cast):
     f = Future(
         legion.legion_runtime_select_tunable_value(
             self._runtime,
             self._context,
             tunable_id,
             self.mapper_id,
             0,
         ))
     return cast(struct.unpack_from("i", f.get_buffer(4))[0])
Exemplo n.º 3
0
 def create_future(self, value, dtype=None):
     if ty.is_categorical_dtype(dtype):
         dtype = ty.string
     if ty.is_string_dtype(dtype):
         return self.create_future_from_string(value)
     pandas_dtype = (dtype.storage_dtype.to_pandas()
                     if dtype is not None else None)
     result = Future()
     value = numpy.array(value, dtype=pandas_dtype)
     if ty.is_timestamp_dtype(dtype):
         value = value.view(dtype.storage_dtype.to_pandas())
     result.set_value(self._runtime, value.data, value.nbytes)
     return PandasFuture(self, result, dtype, ready=True)
Exemplo n.º 4
0
 def measure_nanoseconds(self):
     return Future(
         legion.legion_issue_timing_op_nanoseconds(
             self.runtime, self.context
         )
     )
Exemplo n.º 5
0
 def create_future_from_string(self, value):
     bytes = value.encode("utf-8")
     result = Future()
     result.set_value(self._runtime, bytes, len(bytes))
     return PandasFuture(self, result, dtype=ty.string, ready=True)