deephaven.lang.constants

Deephanven Python language constants.

The contents of this module are intended only for internal Deephaven use and may change at any time.

class VecMode(value)

The various modes of operation for vectorizer.

jit -> basic, prototypical version of the vectorizer. Manually increases the arity of all arguments by 1, optionally takes an output argument at the end of parameters. This may produce a less generalized function, but is less flexible in terms of slicing up input data.

vectorize -> uses @vectorize. Can allow py objects to pass in and out; defaults to nopython=True only if possible (and nopython not explicitly set). @vectorize can return values, and accept optional output array at the end of parameters. This option can perform very efficiently in most cases, and is the default operation.

guvectorize -> uses @guvectorize. Void return type; you supply the output array. This option is more complex, but gives more control of cardinality, and unlocks cuda mode. If you want to, say, pass the length of a list to the function as a scalar value (to avoid wasteful .size checks driving the loop), then you’d need to note that in the numpy signature.

Requires both a numba signature (similar to all others), and a numpy signature (controls arity of arguments) @guvectorize([“void(int32[::1], int32, int32[::1])”], “(n)()->(n)”) def do_stuff(in, len, out):

for i in range(0, len):

out[i] = in[i] + whatever()

cuda -> same as guvec, but runs on graphic card.

Do not use cuda unless your expression is complex enough to warrant IO to graphics card. You must conda install cudatoolkit=9.0 if you expect cuda mode to work. Be sure to benchmark against other options to determine if this is actually better. A plain cpu-bound vectorize can likely win on simple expressions. https://stackoverflow.com/questions/52046102/numba-and-guvectorize-for-cuda-target-code-running-slower-than-expected

cuda = 3

Same as guvectorize, but runs on graphic card.

default_mode = 1

Default mode.

guvectorize = 2

Uses @guvectorize.

jit = 0

Basic, prototypical version of the vectorizer.

vectorize = 1

Uses @vectorize.

debugMode = False

The debug mode. Set to True to get ast dumps.

default_globals()

Gets the default global values when parsing user code.

Returns

default global values

primitive_types = frozenset({<class 'int'>, <class 'numpy.uint32'>, <class 'numpy.int32'>, <class 'numpy.float128'>, <class 'numpy.uint64'>, <class 'numpy.int64'>, <class 'numpy.float64'>, <class 'numpy.uint8'>, <class 'numpy.int8'>, <class 'numpy.float32'>, <class 'numpy.uint16'>, <class 'numpy.int16'>, <class 'numpy.bool_'>})

Primitive numpy types.

timingMode = False

The timing mode. Set to True to get timing info dumps