Texture object state#
Defined in code/simulator.h.
This page documents 15 symbols: 5 enums, 10 functions.
Enums#
Signature |
Description |
Availability |
Location |
Example |
|---|---|---|---|---|
|
sim only |
simulator.h:2988 |
||
|
sim only |
simulator.h:3023 |
||
|
sim only |
simulator.h:2992 |
||
|
sim only |
simulator.h:2996 |
||
|
sim only |
simulator.h:2997 |
Functions#
Signature |
Description |
Availability |
Location |
Example |
|---|---|---|---|---|
|
Apply an address mode to an integer coordinate against extent n. |
sim only |
simulator.h:3037 |
|
|
sim only |
simulator.h:3062 |
||
|
sim only |
simulator.h:3104 |
||
|
sim only |
simulator.h:3094 |
||
|
sim only |
simulator.h:3112 |
||
|
sim only |
simulator.h:3103 |
||
|
sim only |
simulator.h:3029 |
||
|
Raw texel read out of whatever storage the resource uses. |
sim only |
simulator.h:3055 |
|
|
sim only |
simulator.h:3079 |
||
|
sim only |
simulator.h:3028 |
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.
constexpr (test_llmc_matmul_backward_bias.cu:392)
382 for (int k = block_d; k < x128::size; k += blockDim.z) {
383 float a = 0.f;
384 for (int r = warp_d; r < blockDim.z; r += bdx) {
385 float v = sub_results[k][r][warp_c];
386 v += __shfl_down_sync(0xffffffff, v, 1, 4);
387 v += __shfl_down_sync(0xffffffff, v, 2, 4);
388 a += v;
389 }
390 if(warp_d == 0 && global_oc < OC) {
391 // coalesced, but not cacheline-sized
392 if constexpr (!Atomic) {
393 dbias[global_oc + k] = (OutFloat)(a + (float)dbias[global_oc + k]);
394 } else {
395 atomicAdd(dbias + global_oc + k, a);
396 }
397 }
398 }
399}
400
401// Like kernel 8, but instead of accumulating to the auxiliary buffer, it writes
402// multiple values that need to be summed up in a separate kernel call.
403// If UseAuxBuffer is false, gridDim.y has to be one, and results are added directly
cudaCreateTextureObject (test_web_cs_boxfilter.cu:227)
217 cudaTextureDesc texDescr;
218 std::memset(&texDescr, 0, sizeof(cudaTextureDesc));
219 texDescr.normalizedCoords = 0; // [SIM] integer texel coords
220 texDescr.filterMode = cudaFilterModePoint; // [SIM] see header note
221 texDescr.addressMode[0] = cudaAddressModeClamp;
222 texDescr.addressMode[1] = cudaAddressModeClamp;
223 texDescr.readMode = cudaReadModeElementType;
224
225 cudaTextureObject_t tex = 0;
226 check(cudaCreateTextureObject(&tex, &texRes, &texDescr, NULL), "cudaCreateTextureObject");
227
228 float *d_src = nullptr, *d_temp = nullptr, *d_temp2 = nullptr, *d_dest = nullptr;
229 check(cudaMalloc(reinterpret_cast<void**>(&d_src), nByte), "cudaMalloc src");
230 check(cudaMalloc(reinterpret_cast<void**>(&d_temp), nByte), "cudaMalloc temp");
231 check(cudaMalloc(reinterpret_cast<void**>(&d_temp2), nByte), "cudaMalloc temp2");
232 check(cudaMalloc(reinterpret_cast<void**>(&d_dest), nByte), "cudaMalloc dest");
233 check(cudaMemcpy(d_src, hImg.data(), nByte, cudaMemcpyHostToDevice), "cudaMemcpy H2D");
234
235 // Row pass through the texture, then the column pass on global memory.
236 LAUNCH(d_boxfilter_x_tex, dim3(height / nthreads), dim3(nthreads),
237 d_temp, width, height, radius, tex);
cudaDestroyTextureObject (test_web_cs_boxfilter.cu:267)
257 boxFilterRef(hImg, ref, width, height, radius);
258 double maxRel = 0.0;
259 for (size_t i = 0; i < nPix; ++i) {
260 const double den = std::fabs(ref[i]) > 1e-6 ? std::fabs(ref[i]) : 1.0;
261 maxRel = std::max(maxRel, std::fabs((double)hOut[i] - ref[i]) / den);
262 }
263 std::printf("box filter (r=%d, %dx%d) vs direct-sum reference: max rel err = %g\n",
264 radius, width, height, maxRel);
265 if (!(maxRel < 1e-5)) g_ok = false;
266
267 check(cudaDestroyTextureObject(tex), "cudaDestroyTextureObject");
268 check(cudaFreeArray(d_array), "cudaFreeArray");
269 check(cudaFree(d_src), "cudaFree src");
270 check(cudaFree(d_temp), "cudaFree temp");
271 check(cudaFree(d_temp2), "cudaFree temp2");
272 check(cudaFree(d_dest), "cudaFree dest");
273
274 std::printf("boxFilter: %s\n", g_ok ? "PASSED" : "FAILED");
275 return g_ok ? 0 : 1;
276}