Summary
This is an audit of method/member/property naming in the cuda_core API. (A subset of the larger audit work in #1919).
This is a bot-generated list, some of it good, some of it nonsense, and some of it requires some judgement calls.
Instructions for readers of this issue:
- Let's discuss in the comments below
- Once things have consensus, I will mark them with a 👍 or 👎. I have taken the liberty of applying my own judgement as a first pass
- When the change has been merged, the checkbox will get checked
Based on this prompt:
I want to audit the naming of all members of every public class in cuda_core. You can ignore the private classes, I only care about properties and methods exposed through the public API.
- Check for PEP8 compliance
- Properties should be nouns
- Methods should be verbs
- Identify methods that could be properties (i.e. take no arguments and do minimal calculation)
- Check for any naming inconsistencies, such as when different english words or abbreviation forms are used for the same concept or datatype
- Make sure conceptual method pairs are matching, e.g. add/remove, get/set, create/delete
Methods that could be properties
These take no arguments and return a value. Converting to properties would match existing patterns.
system subpackage — no-arg methods that could be properties
Noun-based methods (should be verb-phrased)
Methods named as nouns rather than verbs, making them look like properties.
cuda.core
cuda.core.system
PEP 8 / abbreviation violations
Naming inconsistencies across the API
close() vs destroy()
Every class uses close() for resource cleanup (Buffer, Stream, Event, Program, Linker, Graph, GraphBuilder, GraphicsResource, etc.) except:
allocate()/deallocate() vs alloc()/free()
MemoryResource, Device, _MemPool, GraphMemoryResource all use allocate()/deallocate(), but:
as_ vs to_ conversion prefix
Shared memory naming inconsistency
Three different naming patterns for the same concept:
if_cond abbreviation vs full words elsewhere
add_child() vs embed()
record_event()/wait_event() vs record()/wait()
FanInfo.set_default_fan_speed()
Mismatched conceptual pairs
Properties named as non-nouns or with confusing boolean polarity
Summary
This is an audit of method/member/property naming in the
cuda_coreAPI. (A subset of the larger audit work in #1919).This is a bot-generated list, some of it good, some of it nonsense, and some of it requires some judgement calls.
Instructions for readers of this issue:
Based on this prompt:
I want to audit the naming of all members of every public class in cuda_core. You can ignore the private classes, I only care about properties and methods exposed through the public API.
Methods that could be properties
These take no arguments and return a value. Converting to properties would match existing patterns.
Buffer.get_ipc_descriptor()→ propertyipc_descriptorEvent.get_ipc_descriptor()→ propertyipc_descriptorDeviceMemoryResource.get_allocation_handle()→ propertyallocation_handlePinnedMemoryResource.get_allocation_handle()→ propertyallocation_handleLinker.get_error_log()→ propertyerror_logLinker.get_info_log()→ propertyinfo_logGraphDef.nodes()→ propertynodesGraphDef.edges()→ propertyedgessystemsubpackage — no-arg methods that could be propertiessystem.Device.get_auto_boosted_clocks_enabled()→ propertysystem.Device.get_current_clock_event_reasons()→ propertysystem.Device.get_supported_clock_event_reasons()→ propertysystem.Device.get_supported_event_types()→ propertysystem.Device.get_supported_pstates()→ propertysystem.PciInfo.get_pcie_replay_counter()→ propertysystem.PciInfo.get_max_pcie_link_generation()→ propertysystem.PciInfo.get_gpu_max_pcie_link_generation()→ propertysystem.PciInfo.get_max_pcie_link_width()→ propertysystem.PciInfo.get_current_pcie_link_generation()→ propertysystem.PciInfo.get_current_pcie_link_width()→ propertyNoun-based methods (should be verb-phrased)
Methods named as nouns rather than verbs, making them look like properties.
cuda.coreKernelAttributes.max_threads_per_block(device_id)— noun phrase (takes param so can't be property; considerget_prefix)KernelAttributes.shared_size_bytes(device_id)— sameKernelAttributes.const_size_bytes(device_id)— sameKernelAttributes.local_size_bytes(device_id)— sameKernelAttributes.num_regs(device_id)— sameKernelAttributes.ptx_version(device_id)— sameKernelAttributes.binary_version(device_id)— sameKernelAttributes.cache_mode_ca(device_id)— sameKernelAttributes.max_dynamic_shared_size_bytes(device_id)— sameKernelAttributes.preferred_shared_memory_carveout(device_id)— sameKernelAttributes.cluster_size_must_be_set(device_id)— sameKernelAttributes.required_cluster_width(device_id)— sameKernelAttributes.required_cluster_height(device_id)— sameKernelAttributes.required_cluster_depth(device_id)— sameKernelAttributes.non_portable_cluster_size_allowed(device_id)— sameKernelAttributes.cluster_scheduling_policy_preference(device_id)— sameKernelOccupancy.max_active_blocks_per_multiprocessor()— noun phraseKernelOccupancy.max_potential_block_size()— noun phraseKernelOccupancy.available_dynamic_shared_memory_per_block()— noun phraseKernelOccupancy.max_potential_cluster_size()— noun phraseKernelOccupancy.max_active_clusters()— noun phraseGraphDef.empty()/GraphNode.empty()— adjective, not verb; considercreate_empty_node()oradd_empty()cuda.core.systemsystem.Device.clock(clock_type)— noun; considerget_clock_info()system.Device.fan(fan)— noun; considerget_fan_info()system.Temperature.sensor(sensor)— noun; considerget_sensor_reading()system.Temperature.threshold(type)— noun; considerget_threshold()system.Temperature.thermal_settings(idx)— noun phrase; considerget_thermal_settings()PEP 8 / abbreviation violations
Stream.is_nonblocking→is_non_blocking(PEP 8 snake_case word boundary)GraphNode.pred/GraphNode.succ→predecessors/successorsAllocNode.dptr/FreeNode.dptr/MemsetNode.dptr→device_pointerorpointerAllocNode.bytesize→byte_sizeorsizeConditionalNode.cond_type→condition_typeHostCallbackNode.callback_fn→callbackLaunchConfig.shmem_size→shared_memory_sizeGraphBuilder.if_cond()/GraphDef.if_cond()/GraphNode.if_cond()→if_condition()GpuDynamicPstatesUtilization.inc_threshold/dec_threshold→increase_threshold/decrease_thresholdFanInfo.speed_rpm→speed_in_rpm(match "units in name" pattern)InforomInfo.bbx_flush_time→blackbox_flush_timeNaming inconsistencies across the API
close()vsdestroy()Every class uses
close()for resource cleanup (Buffer,Stream,Event,Program,Linker,Graph,GraphBuilder,GraphicsResource, etc.) except:GraphNode.destroy()— sole exception; should beclose()for consistencyallocate()/deallocate()vsalloc()/free()MemoryResource,Device,_MemPool,GraphMemoryResourceall useallocate()/deallocate(), but:GraphDef.alloc()→allocate()for consistencyGraphDef.free()→deallocate()for consistencyGraphNode.alloc()→allocate()for consistencyGraphNode.free()→deallocate()for consistencyas_vsto_conversion prefixStridedMemoryView.as_tensor_map()usesas_whileDevice.to_system_device()/system.Device.to_cuda_device()useto_— pick one conventionShared memory naming inconsistency
Three different naming patterns for the same concept:
LaunchConfig.shmem_sizevsKernelAttributes.shared_size_bytes/max_dynamic_shared_size_bytesvsDeviceProperties.max_shared_memory_per_block— unify namingif_condabbreviation vs full words elsewhereGraphBuilder.create_conditional_handle()(full) alongsideGraphBuilder.if_cond()(abbreviated) — inconsistentGraphDef.create_condition()(full) alongsideGraphDef.if_cond()(abbreviated) — inconsistentadd_child()vsembed()GraphBuilder.add_child()vsGraphDef.embed()— same concept (embed a child graph) with different names across the two graph-building interfacesrecord_event()/wait_event()vsrecord()/wait()GraphDef.record_event()/GraphDef.wait_event()include type name "event", whileStream.record()/Stream.wait()drop it — inconsistentFanInfo.set_default_fan_speed()FanInfoobject; considerreset_speed()orset_default_speed()Mismatched conceptual pairs
get_ipc_descriptor()/from_ipc_descriptor()—get_doesn't pair withfrom_; considerexport_ipc()/from_ipc()or make getter a propertyget_allocation_handle()/from_allocation_handle()— same mismatchProperties named as non-nouns or with confusing boolean polarity
LaunchConfig.cooperative_launch— reads like an action;is_cooperativewould be more idiomatic for a booleanEvent.is_timing_disabled— negative boolean;is_timing_enabledavoids double-negatives likenot event.is_timing_disabledEvent.is_sync_busy_waited— grammatically awkward;uses_busy_waitoris_busy_wait_enabledsystem.Device.persistence_mode_enabled— missingis_prefix for boolean;is_persistence_mode_enabledsystem.Device.display_mode— returns bool but name doesn't suggest boolean;is_display_connectedsystem.Device.display_active— returns bool but name doesn't suggest boolean;is_display_activesystem.Device.is_c2c_mode_enabled— verbose;is_c2c_enabled