Skip to content

Commit 9e8eaf1

Browse files
LessUpCopilot
andcommitted
Clarify DeviceInfoProvider contract and field semantics
- Document that prop pointer must never be null - Add @pre prop != nullptr preconditions to all accessors - Clarify that cores_per_sm and clock_ghz are precomputed adapter values (not directly from cudaDeviceProp) for testability and metric calculations - Document prop lifetime requirement Fixes quality issues in Task 5 device_info_provider.cuh Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7a3f25a commit 9e8eaf1

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/utils/device_info_provider.cuh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,46 @@
2121
*
2222
* Provides a minimal surface for querying GPU capabilities needed by
2323
* Tensor Core logic and benchmark calculations.
24+
*
25+
* Contract:
26+
* - `prop` must never be null; all accessors dereference without null checks
27+
* - `prop` must remain valid for the lifetime of this provider instance
28+
* - `cores_per_sm` and `clock_ghz` are precomputed adapter values carried for
29+
* testability and metric calculations; they are NOT directly queryable from
30+
* cudaDeviceProp and must be supplied by the provider (e.g., via
31+
* DeviceInfoCache architecture tables or test fixtures)
2432
*/
2533
struct DeviceInfoProvider {
2634
const cudaDeviceProp *prop;
2735
int cores_per_sm;
2836
float clock_ghz;
2937

3038
/// Check if device supports Tensor Cores (sm_70+)
39+
/// @pre prop != nullptr
3140
bool hasTensorCores() const { return prop->major >= 7; }
3241

3342
/// Get compute capability major version
43+
/// @pre prop != nullptr
3444
int computeMajor() const { return prop->major; }
3545

3646
/// Get compute capability minor version
47+
/// @pre prop != nullptr
3748
int computeMinor() const { return prop->minor; }
3849

3950
/// Get number of streaming multiprocessors
51+
/// @pre prop != nullptr
4052
int smCount() const { return prop->multiProcessorCount; }
4153

4254
/// Get memory bus width in bits
55+
/// @pre prop != nullptr
4356
int memoryBusWidth() const { return prop->memoryBusWidth; }
4457

4558
/// Get memory clock rate in kHz
59+
/// @pre prop != nullptr
4660
int memoryClockRate() const { return prop->memoryClockRate; }
4761

4862
/// Get clock rate in kHz
63+
/// @pre prop != nullptr
4964
int clockRate() const { return prop->clockRate; }
5065
};
5166

0 commit comments

Comments
 (0)