< GeeXLab Reference Guide />
> Back to Reference Guide Index
gh_cuda library
Description
gh_cuda is the module that manages CUDA functions. Currently CUDA functions only covers the API level support of CUDA-capable devices.
Number of functions: 9
- gh_cuda.device_get_attribute_1i ()
- gh_cuda.device_get_attribute_2i ()
- gh_cuda.device_get_attribute_3i ()
- gh_cuda.device_get_name ()
- gh_cuda.device_get_pci_bus_id_string ()
- gh_cuda.device_get_total_memory ()
- gh_cuda.get_driver_version ()
- gh_cuda.get_num_devices ()
- gh_cuda.sm_version_to_num_cores ()
device_get_attribute_1i
Description
Returns the value of an attribute of a CUDA device.
Syntax
x = gh_cuda.device_get_attribute_1i(
dev_index,
attr_name
)
Languages
Parameters
- dev_index [INTEGER]: device index
- attr_name [ENUM]: attribute name
Return Values
- x [INTEGER]: attribute value
Code sample
--[[
"simd_width"
"mem_pitch"
"registers_per_block"
"texture_align"
"core_clock_rate"
"mem_clock_rate"
"mem_bus_width"
"mem_bandwidth_gbs"
"pci_bus_id"
"l2_cache_size"
"async_count"
"total_constant_memory"
"shared_mem_per_block"
"max_shared_mem_per_sm"
"max_threads_per_block"
"max_threads_per_sm"
"warp_size"
"multiprocessor_count"
"cuda_cores_per_sm"
"cuda_cores"
--]]
attribute = "multiprocessor_count"
x = gh_cuda.device_get_attribute_1i(0, attribute)
device_get_attribute_2i
Description
Returns the value of an attribute of a CUDA device.
Syntax
x, y = gh_cuda.device_get_attribute_2i(
dev_index,
attr_name
)
Languages
Parameters
- dev_index [INTEGER]: device index
- attr_name [ENUM]: attribute name
Return Values
- x, y [INTEGER]: attribute value
Code sample
attribute = "compute_capability"
x, y = gh_cuda.device_get_attribute_2i(0, attribute)
device_get_attribute_3i
Description
Returns the value of an attribute of a CUDA device.
Syntax
x, y, z = gh_cuda.device_get_attribute_3i(
dev_index,
attr_name
)
Languages
Parameters
- dev_index [INTEGER]: device index
- attr_name [ENUM]: attribute name
Return Values
- x, y, z [INTEGER]: attribute value
Code sample
-- "max_threads_dim"
-- "max_grid_size"
-- "max_block_dim"
attribute = "max_threads_dim"
x, y, z = gh_cuda.device_get_attribute_3i(0, attribute)
device_get_name
Description
Returns the name of a CUDA device.
Syntax
dev_name = gh_cuda.device_get_name(
dev_index
)
Languages
Parameters
- dev_index [INTEGER]: device index
Return Values
- dev_name [STRING]: name the CUDA device
Code sample
name = gh_cuda.device_get_name(0)
device_get_pci_bus_id_string
Description
Returns the PCI bus ID string of a CUDA device.
Syntax
pci_bus_id_str = gh_cuda.device_get_pci_bus_id_string(
dev_index
)
Languages
Parameters
- dev_index [INTEGER]: device index
Return Values
- pci_bus_id_str [STRING]: PCI bus ID string
Code sample
pci_bus_id_str = gh_cuda.device_get_pci_bus_id_string(0)
device_get_total_memory
Description
Returns the total amount of memory of a CUDA device.
Syntax
total_memory = gh_cuda.device_get_total_memory(
dev_index
)
Languages
Parameters
- dev_index [INTEGER]: device index
Return Values
- total_memory [INTEGER]: memory amount in bytes
Code sample
total_memory = gh_cuda.device_get_total_memory(0)
get_driver_version
Description
Returns the version of CUDA supported by the graphics driver.
Syntax
version = gh_cuda.get_driver_version()
Languages
Parameters
This function has no input parameter(s).
Return Values
- version [INTEGER]: version
Code sample
version = gh_cuda.get_driver_version()
get_num_devices
Description
Returns the number of CUDA devices available.
Syntax
num_devices = gh_cuda.get_num_devices()
Languages
Parameters
This function has no input parameter(s).
Return Values
- num_devices [INTEGER]: number of CUDA devices
Code sample
num_devices = gh_cuda.get_num_devices()
sm_version_to_num_cores
Description
Utility function that returns the number of cores per SM (CUDA multiprocessor) from a CUDA compute capability.
Syntax
num_cores_per_sm = gh_cuda.sm_version_to_num_cores(
cc_major,
cc_minor
)
Languages
Parameters
- cc_major [INTEGER]: major version of compute capability
- cc_minor [INTEGER]: minor version of compute capability
Return Values
- num_cores_per_sm [INTEGER]: number of cores per SM
Code sample
num_cores_per_sm = gh_cuda.sm_version_to_num_cores(6, 0)
| |