Device attributes#
Defined in code/simulator.h.
This page documents 2 symbols: 1 enums, 1 functions.
Enums#
Signature |
Description |
Availability |
Location |
Example |
|---|---|---|---|---|
|
sim only |
simulator.h:2284 |
Functions#
Signature |
Description |
Availability |
Location |
Example |
|---|---|---|---|---|
|
sim only |
simulator.h:2300 |
Examples#
Code from the repository’s example corpus (code\*.cu); the highlighted line is the call site. These blocks are what the View links above open.
cudaDeviceGetAttribute (test_web_pk_mixed_precision.cu:153)
143 // Host data. CBuffer::init() draws (rand() & 0xFF) / RAND_MAX for types of
144 // 2 bytes or more, which is what both the FP32 and FP16 runs get here.
145 std::vector<float> h_x(size), h_y(size), h_ref(size); // [SIM] was CBuffer<>
146 for (int i = 0; i < size; ++i) h_x[i] = float(std::rand() & 0xFF) / float(RAND_MAX);
147 for (int i = 0; i < size; ++i) h_y[i] = float(std::rand() & 0xFF) / float(RAND_MAX);
148 fma_host(h_x, h_y, h_ref);
149
150 const int n_threads = 256;
151 int num_sms = 0, num_blocks_per_sm = 0;
152 check(cudaDeviceGetAttribute(&num_sms, cudaDevAttrMultiProcessorCount, 0),
153 "cudaDeviceGetAttribute");
154
155 cudaEvent_t start, stop;
156 check(cudaEventCreate(&start), "cudaEventCreate(start)");
157 check(cudaEventCreate(&stop), "cudaEventCreate(stop)");
158
159 // ---------------- FP32 ----------------
160 {
161 float *d_x = nullptr, *d_y = nullptr, *d_z = nullptr;
162 check(cudaMalloc((void**)&d_x, size * sizeof(float)), "cudaMalloc(d_x)");
163 check(cudaMalloc((void**)&d_y, size * sizeof(float)), "cudaMalloc(d_y)");