Added documentation for cupy.core.raw.FunctionAttributes.
@@ -57,8 +57,7 @@ cdef class RawKernel:
Returns:
attributes (FunctionAttributes): A python class containing the
- kernel's attributes. For example, ``attributes.num_regs``
- corresponds to the number of registers used by the kernel.
+ kernel's attributes.
"""
return FunctionAttributes(self.kernel)
@@ -75,33 +74,73 @@ def _get_raw_kernel(code, name, options=()):
class FunctionAttributes(object):
+ """CUDA function attributes for a RawKernel.
+
+ An attribute is read-only unless its documentation states otherwise.
+ """
class Read(object):
def __init__(self, func_attribute):
self.func_attribute = func_attribute
def __get__(self, instance, owner):
+ if instance is not None:
return driver.funcGetAttribute(self.func_attribute,
instance.kern.ptr)
class ReadWrite(Read):
def __set__(self, instance, value):
+ if instance is not None:
driver.funcSetAttribute(instance.kern.ptr, self.func_attribute,
value)
- shared_size_bytes = Read(driver.CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES)
- const_size_bytes = Read(driver.CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES)
- local_size_bytes = Read(driver.CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES)
max_threads_per_block = Read(
driver.CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK)
+ """The maximum number of threads per block that can successfully
+ launch the function on the device.
+ """
+
+ shared_size_bytes = Read(
+ driver.CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES)
+ """The size in bytes of the statically-allocated shared memory
+ used by the function. This is separate from any dynamically-allocated
+ shared memory, which must be specified when the function is called.
+ """
+
+ const_size_bytes = Read(driver.CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES)
+ "The size in bytes of constant memory used by the function."
+
+ local_size_bytes = Read(driver.CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES)
+ "The size in bytes of local memory used by the function."
+
num_regs = Read(driver.CU_FUNC_ATTRIBUTE_NUM_REGS)
+ "The number of registers used by the function."
+
ptx_version = Read(driver.CU_FUNC_ATTRIBUTE_PTX_VERSION)
+ """The PTX virtual architecture version that was used during compilation,
+ in the format: major*10 + minor.
+ """
+
binary_version = Read(driver.CU_FUNC_ATTRIBUTE_BINARY_VERSION)
+ """The binary architecture version that was used during compilatin,
+ in the format: major*10 + minor.
+ """
+
cache_mode_ca = Read(driver.CU_FUNC_ATTRIBUTE_CACHE_MODE_CA)
+ 'Indicates whether option "-Xptxas --dlcm=ca" was set during compilation.'
+
max_dynamic_shared_size_bytes = ReadWrite(
driver.CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES)
+ """The maximum dynamically-allocated shared memory size in bytes that can
+ be used by the function. Can be set.
+ """
+
preferred_shared_memory_carveout = ReadWrite(
driver.CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT)
+ """On devices that have a unified L1 cache and shared memory, specifies the
+ preferred amount devoted to shared memory as a percentage of the total.
+ Can be set.
+ """
def __init__(self, kern):
self.kern = kern
