Skip to content

Commit f4ac899

Browse files
author
Felix Igelbrink
committed
added maximum launch size checking on pipeline launch
1 parent 82e8e0b commit f4ac899

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

optix/context.pyx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ cdef void context_log_cb(unsigned int level, const char * tag, const char * mess
2121
cb_object(level, tag.decode(), message.decode())
2222

2323

24+
cdef size_t MAXIMUM_LAUNCH_SIZE = 2**30
25+
26+
2427
cdef class DeviceContext(OptixObject):
2528
"""
2629
Represents an OptiX context on a single device. This class wraps the OptixDeviceContext struct.
@@ -233,6 +236,14 @@ cdef class DeviceContext(OptixObject):
233236
"""
234237
return self._device
235238

239+
@property
240+
def maximum_launch_size(self):
241+
"""
242+
The maximum launch size (over width, height, depth) of a single pipeline launch
243+
"""
244+
return MAXIMUM_LAUNCH_SIZE
245+
246+
236247
def _repr_details(self):
237248
return f"device id {self._device.id}"
238249

optix/pipeline.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,10 @@ cdef class Pipeline(OptixContextObject):
405405
for i in range(len(dimensions)):
406406
c_dims[i] = dimensions[i]
407407

408+
cdef size_t total_launch_size = c_dims[0] * c_dims[1] * c_dims[2]
409+
if total_launch_size > self.context.maximum_launch_size:
410+
raise ValueError(f"Requested launch size of {total_launch_size} is larger than the limit of {self.context.maximum_launch_size} set by OptiX.")
411+
408412
cdef size_t c_stream = 0
409413
if stream is not None:
410414
c_stream = stream.ptr

0 commit comments

Comments
 (0)