mmp / pbrt-v4

Source code to pbrt, the ray tracer described in the forthcoming 4th edition of the "Physically Based Rendering: From Theory to Implementation" book.
https://pbrt.org
Apache License 2.0
2.75k stars 407 forks source link

A question about CUDA constant memory initialization. #430

Closed HuazyYang closed 3 weeks ago

HuazyYang commented 3 weeks ago

In file spectrum.cpp:2596-2602, I read xGPU, yGPU, zGPU uploading logic where xGPU does not allocate any device memory. Does this make sense for cudaMemcpyToSymbol if device memory address is not allocated but the API call succeed?

#ifdef PBRT_BUILD_GPU_RENDERER
    if (Options->useGPU) {
        CUDA_CHECK(cudaMemcpyToSymbol(xGPU, &x, sizeof(x)));
        CUDA_CHECK(cudaMemcpyToSymbol(yGPU, &y, sizeof(y)));
        CUDA_CHECK(cudaMemcpyToSymbol(zGPU, &z, sizeof(z)));
    }
#endif
mmp commented 3 weeks ago

(And just to close the loop for anyone else wondering about this: the key is that the Allocator passed to the Init() function there allocates memory on the GPU when GPU rendering is enabled.)

On Jun 25, 2024, at 8:55 AM, Wang Yonghong @.***> wrote:

Closed #430 https://github.com/mmp/pbrt-v4/issues/430 as completed.

— Reply to this email directly, view it on GitHub https://github.com/mmp/pbrt-v4/issues/430#event-13283844499, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAZBJZQPEE7H66QZTSN7I3ZJGHIRAVCNFSM6AAAAABJ3TSGV2VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJTGI4DGOBUGQ2DSOI. You are receiving this because you are subscribed to this thread.