Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile issues with Visual Studio 2019 #20

Closed
richardmgoodin opened this issue Aug 27, 2020 · 106 comments
Closed

Compile issues with Visual Studio 2019 #20

richardmgoodin opened this issue Aug 27, 2020 · 106 comments

Comments

@richardmgoodin
Copy link

I apologize in advance as I'm new to Windows and CMake. I'm getting two classes of compile errors. The first is nvcc.

Here's my command line:
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe" -gencode=arch=compute_70,code="sm_70,compute_70" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64" -x cu -rdc=true -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -I"C:\ProgramData\NVIDIA Corporation\OptiX SDK 7.1.0\include" -I"C:\cygwin64\home\goodin\pbrt-v4\src" -I"C:\cygwin64\home\goodin\pbrt-v4\build" -I"C:\cygwin64\home\goodin\pbrt-v4\src\ext" -I"C:\cygwin64\home\goodin\pbrt-v4\src\ext\stb" -I"C:\cygwin64\home\goodin\pbrt-v4\src\ext\openexr\IlmBase\Imath" -I"C:\cygwin64\home\goodin\pbrt-v4\src\ext\openexr\IlmBase\Half" -I"C:\cygwin64\home\goodin\pbrt-v4\src\ext\openexr\IlmBase\Iex" -I"C:\cygwin64\home\goodin\pbrt-v4\src\ext\openexr\OpenEXR\IlmImf" -I"C:\cygwin64\home\goodin\pbrt-v4\build\src\ext\openexr\IlmBase\config" -I"C:\cygwin64\home\goodin\pbrt-v4\build\src\ext\openexr\OpenEXR\config" -I"C:\cygwin64\home\goodin\pbrt-v4\src\ext\zlib" -I"C:\cygwin64\home\goodin\pbrt-v4\build\src\ext\zlib" -I"C:\cygwin64\home\goodin\pbrt-v4\src\ext\filesystem" -I"C:\cygwin64\home\goodin\pbrt-v4\src\ext\ptex\src\ptex" -I"C:\cygwin64\home\goodin\pbrt-v4\src\ext\double-conversion" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -Xcudafe --diag_suppress=partial_override -Xcudafe --diag_suppress=virtual_function_decl_hidden -Xcudafe --diag_suppress=integer_sign_change -Xcudafe --diag_suppress=declared_but_not_referenced -Xcudafe --diag_suppress=implicit_return_from_non_void_function --expt-relaxed-constexpr --extended-lambda -Xnvlink -suppress-stack-size-warning --std=c++17 /wd4305 /wd4244 /wd4843 /wd4267 /wd4838 /wd26495 /wd26451 -Xcompiler="/EHsc -Zi -Ob0" -g -use_fast_math -D_WINDOWS -D_CRT_SECURE_NO_WARNINGS -DPBRT_IS_MSVC -DPBRT_BUILD_GPU_RENDERER -DNVTX -DPBRT_HAS_INTRIN_H -DPBRT_IS_WINDOWS -DNOMINMAX -D"PBRT_NOINLINE=__declspec(noinline)" -DPBRT_HAVE__ALIGNED_MALLOC -DPTEX_STATIC -D"CMAKE_INTDIR="Debug"" -DWIN32 -D_WINDOWS -D_CRT_SECURE_NO_WARNINGS -DPBRT_IS_MSVC -DPBRT_BUILD_GPU_RENDERER -DNVTX -DPBRT_HAS_INTRIN_H -DPBRT_IS_WINDOWS -DNOMINMAX -D"PBRT_NOINLINE=__declspec(noinline)" -DPBRT_HAVE__ALIGNED_MALLOC -DPTEX_STATIC -D"CMAKE_INTDIR="Debug"" -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Fdpbrt_lib.dir\Debug\pbrt_lib.pdb /FS /Zi /RTC1 /MDd /GR" -o pbrt_lib.dir\Debug\cameras.obj "C:\cygwin64\home\goodin\pbrt-v4\src\pbrt\cameras.cpp"

I'm getting the following error:

nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified

When I run the command standalone it still fails. When I remove the output file it thinks the "/wd4305" is a file.

The second is an error:
C:/cygwin64/home/goodin/pbrt-v4/src\pbrt/util/image.h(317): warning #3059-D: calling a host function from a host device function is not allowed
C:/cygwin64/home/goodin/pbrt-v4/src\pbrt/textures.h(682): error #349: no operator "=" matches these operands
operand types are: pbrt::RGB = COLORREF
C:/cygwin64/home/goodin/pbrt-v4/src\pbrt/textures.h(685): error #349: no operator "=" matches these operands
operand types are: pbrt::RGB = float
C:/cygwin64/home/goodin/pbrt-v4/src\pbrt/util/spectrum.cpp(268): error #42: operand types are incompatible ("pbrt::RGB" and "COLORREF")

@richardmgoodin
Copy link
Author

Just commenting to confirm when I remove PBRT_OPTIX7_PATH the code compiles fine.

@wangchi87
Copy link

wangchi87 commented Aug 27, 2020

I get the errors on VS2019 as well when CUDA and Optix is turned on:

  1. #include <sys/syscall.h> was not found
  2. MSB3721: “"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe" -gencode=arch=compute_75,code="sm_75,compute_75" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64" -x cu -rdc=true -I"C:\ProgramData\NVIDIA Corporation\OptiX SDK 7.1.0\include" -I"D:\code\pbrt-v4\src" -I"D:\code\pbrt-v4\build_gpu" -I"D:\code\pbrt-v4\src\ext\openvdb\nanovdb" -I"D:\code\pbrt-v4\src\ext" -I"D:\code\pbrt-v4\src\ext\stb" -I"D:\code\pbrt-v4\src\ext\openexr\IlmBase\Imath" -I"D:\code\pbrt-v4\src\ext\openexr\IlmBase\Half" -I"D:\code\pbrt-v4\src\ext\openexr\IlmBase\Iex" -I"D:\code\pbrt-v4\src\ext\openexr\OpenEXR\IlmImf" -I"D:\code\pbrt-v4\build_gpu\src\ext\openexr\IlmBase\config" -I"D:\code\pbrt-v4\build_gpu\src\ext\openexr\OpenEXR\config" -I"D:\code\pbrt-v4\src\ext\zlib" -I"D:\code\pbrt-v4\build_gpu\src\ext\zlib" -I"D:\code\pbrt-v4\src\ext\filesystem" -I"D:\code\pbrt-v4\src\ext\ptex\src\ptex" -I"D:\code\pbrt-v4\src\ext\double-conversion" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -G --keep-dir x64\Release -maxrregcount=0 --machine 64 --compile -cudart static -Xcudafe --diag_suppress=partial_override -Xcudafe --diag_suppress=virtual_function_decl_hidden -Xcudafe --diag_suppress=integer_sign_change -Xcudafe --diag_suppress=declared_but_not_referenced -Xcudafe --diag_suppress=implicit_return_from_non_void_function --expt-relaxed-constexpr --extended-lambda -Xnvlink -suppress-stack-size-warning --std=c++17 /wd4305 /wd4244 /wd4843 /wd4267 /wd4838 /wd26495 /wd26451 -Xcompiler="/EHsc -Ob2" -g -use_fast_math -D_WINDOWS -DNDEBUG -D_CRT_SECURE_NO_WARNINGS -DPBRT_IS_MSVC -DPBRT_BUILD_GPU_RENDERER -DNVTX -DPBRT_HAS_INTRIN_H -DPBRT_IS_WINDOWS -DNOMINMAX -D"PBRT_NOINLINE=__declspec(noinline)" -DPBRT_HAVE__ALIGNED_MALLOC -DPTEX_STATIC -D"CMAKE_INTDIR="Release"" -DWIN32 -D_WINDOWS -DNDEBUG -D_CRT_SECURE_NO_WARNINGS -DPBRT_IS_MSVC -DPBRT_BUILD_GPU_RENDERER -DNVTX -DPBRT_HAS_INTRIN_H -DPBRT_IS_WINDOWS -DNOMINMAX -D"PBRT_NOINLINE=__declspec(noinline)" -DPBRT_HAVE__ALIGNED_MALLOC -DPTEX_STATIC -D"CMAKE_INTDIR="Release"" -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /Fdpbrt_lib.dir\Release\pbrt_lib.pdb /FS /Zi /MD /GR" -o pbrt_lib.dir\Release\samples.obj "D:\code\pbrt-v4\src\pbrt\gpu\samples.cpp"” returned code 1。 pbrt_lib C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 11.0.targets 772

@wuyakuma
Copy link
Contributor

nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified

Comment out those lines(79~85) in CMakeList.txt fix this error for me

list (APPEND PBRT_CXX_FLAGS /wd4305) # double constant assigned to float
list (APPEND PBRT_CXX_FLAGS /wd4244) # int -> float conversion
list (APPEND PBRT_CXX_FLAGS /wd4843) # double -> float conversion
list (APPEND PBRT_CXX_FLAGS /wd4267) # size_t -> int conversion
list (APPEND PBRT_CXX_FLAGS /wd4838) # double -> int conversion
list (APPEND PBRT_CXX_FLAGS /wd26495) # uninitialized member variable
list (APPEND PBRT_CXX_FLAGS /wd26451) # arithmetic on 4-byte value, then cast to 8-byte

@mmp
Copy link
Owner

mmp commented Aug 28, 2020

I am admittedly not very good with Windows and (embarrassingly) don't have a Windows system with a GPU at hand at the moment. I made the very first issue, #1, on this issue for that reason. If we can together figure out how to get the windows+GPU build working, that'd be fantastic..

Note that if you don't define PBRT_OPTIX7_PATH, then you don't get GPU support. And what fun is that? :-)

I expect that the sys/syscall.h thing can be fixed by putting those #includes inside #ifndef PBRT_IS_WINDOWS checks. I can preemptively do that tomorrow (but can't confirm the fix.)

That makes sense that commenting out those lines helps, @wuyakuma. I can definitely see that the CUDA compiler isn't going to think those make sense. I can also try to fix that on my side, to pass those to MSVC but not to NVCC. With that fix, does it build and run on the GPU for you?

@richardmgoodin
Copy link
Author

Removing the warning ignores got me farther but I'm still seeing some hard errors in the GPU code. I'll do another build tomorrow and update this thread

@mmp
Copy link
Owner

mmp commented Aug 28, 2020 via email

@jiangwei007
Copy link

When i'm compiling GPU version of PBRT on windows, visual studio 2019 ,i got this : error #349: no operator "=" matches these operands
operand types are: pbrt::RGB = COLORREF

@richardmgoodin
Copy link
Author

Here's what I'm seeing:
First error:

C:/cygwin64/home/goodin/pbrt-v4/src\pbrt/util/spectrum.cpp(255): error #42: operand types are incompatible ("pbrt::RGB" and "COLORREF")

Here's the code:

RGBSpectrum::RGBSpectrum(const RGBColorSpace &cs, const RGB &rgb)
: rgb(rgb), illuminant(&cs.illuminant) {
Float m = std::max({rgb.r, rgb.g, rgb.b});
scale = 2 * m;
rsp = cs.ToRGBCoeffs(scale ? rgb / scale : RGB(0, 0, 0)); <---
}

This fixes the compile but I'm not sure it is correct:
RGBSpectrum::RGBSpectrum(const RGBColorSpace &cs, const RGB &rgb)
: rgb(rgb), illuminant(&cs.illuminant) {
Float m = std::max({rgb.r, rgb.g, rgb.b});
// RMG
RGB black(0, 0, 0);
// RMG
scale = 2 * m;
// RMG
rsp = cs.ToRGBCoeffs(scale ? rgb / scale : black);
// RMG rsp = cs.ToRGBCoeffs(scale ? rgb / scale : RGB(0, 0, 0));
}

Second Error:
C:\cygwin64\home\goodin\pbrt-v4\src\pbrt/util/pstd.h(86): error : incomplete type is not allowed
detected during instantiation of class "pstd::array<T, N> [with T=int, N=0]"
C:/cygwin64/home/goodin/pbrt-v4/src/pbrt/bxdfs.cpp(764): here

C:\cygwin64\home\goodin\pbrt-v4\src\pbrt/util/pstd.h(86): error : incomplete type is not allowed
detected during instantiation of class "pstd::array<T, N> [with T=const float *, N=0]"
C:/cygwin64/home/goodin/pbrt-v4/src/pbrt/bxdfs.cpp(764): here

Here's the code, not sure what it doesn't like:

bxdfs.cpp
/* Construct NDF interpolant data structure */
brdf->ndf = Warp2D0(alloc, (float *)ndf.data.get(), ndf.shape[1], ndf.shape[0], {},
{}, false, false);

pstd.h:
template <typename T, int N>
class array {
public:
using value_type = T;
using iterator = value_type *;
using const_iterator = const value_type *;
using size_t = std::size_t;

array() = default;
PBRT_CPU_GPU
array(std::initializer_list<T> v) {
    size_t i = 0;
    for (const T &val : v)
        values[i++] = val;
}

PBRT_CPU_GPU
void fill(const T &v) {
    for (int i = 0; i < N; ++i)
        values[i] = v;
}

PBRT_CPU_GPU
bool operator==(const array<T, N> &a) const {
    for (int i = 0; i < N; ++i)
        if (values[i] != a.values[i])
            return false;
    return true;
}
PBRT_CPU_GPU
bool operator!=(const array<T, N> &a) const { return !(*this == a); }

PBRT_CPU_GPU
iterator begin() { return values; }
PBRT_CPU_GPU
iterator end() { return values + N; }
PBRT_CPU_GPU
const_iterator begin() const { return values; }
PBRT_CPU_GPU
const_iterator end() const { return values + N; }

PBRT_CPU_GPU
size_t size() const { return N; }

PBRT_CPU_GPU
T &operator[](size_t i) { return values[i]; }
PBRT_CPU_GPU
const T &operator[](size_t i) const { return values[i]; }

PBRT_CPU_GPU
T *data() { return values; }
PBRT_CPU_GPU
const T *data() const { return values; }

private:
T values[N] = {};
};

Third error:
C:/cygwin64/home/goodin/pbrt-v4/src/pbrt/gpu/pathintegrator.cpp(276): error : identifier "SYS_gettid" is undefined

C:/cygwin64/home/goodin/pbrt-v4/src/pbrt/gpu/pathintegrator.cpp(276): error : identifier "syscall" is undefined

The code:
#ifdef NVTX
nvtxNameOsThread(syscall(SYS_gettid), "DISPLAY_SERVER_COPY_THREAD");
#endif

Fourth error:
C:/cygwin64/home/goodin/pbrt-v4/src/pbrt/gpu/film.cpp(22): error : calling a host function("isnan ") from a device function(" const") is not allowed

C:/cygwin64/home/goodin/pbrt-v4/src/pbrt/gpu/film.cpp(22): error : identifier "isnan " is undefined in device code

The code:
// Compute final weighted radiance value
SampledSpectrum Lw = SampledSpectrum(pixelSampleState.L[pixelIndex]) *
pixelSampleState.cameraRayWeight[pixelIndex];
CHECK(!std::isnan(Lw[0]));

@wuyakuma
Copy link
Contributor

wuyakuma commented Aug 28, 2020

@mmp
Here is what I did:

After commenting out those warning, I got

nvcc fatal: Cannot find compiler 'cl.exe' in PATH

so I changed line 142 in CMakeLists.txt to

if (MSVC)
  execute_process (COMMAND nvcc -lcuda ${CMAKE_SOURCE_DIR}/cmake/checkcuda.cu -ccbin ${CMAKE_CXX_COMPILER} -o ${OUTPUTFILE})
else  ()
  execute_process (COMMAND nvcc -lcuda ${CMAKE_SOURCE_DIR}/cmake/checkcuda.cu -o ${OUTPUTFILE})
endif ()

and also the BUILD_SHARED_LIBS need to be set to ON

set (BUILD_SHARED_LIBS ON)

otherwise the IlmImf project will staticlib, which causes link errors

after this

add
#include <algorithm>
in launch.cpp to fix

D:/RayTracing/pbrt/pbrt-v4/src/pbrt/gpu/launch.cpp(42): error : namespace "std" has no member "min"
D:/RayTracing/pbrt/pbrt-v4/src/pbrt/gpu/launch.cpp(43): error : namespace "std" has no member "max"

and

D:\RayTracing\pbrt\pbrt-v4\src\pbrt/util/pstd.h(86): error : incomplete type is not allowed detected during instantiation of class "pstd::array<T, N> [with T=int, N=0]"
D:/RayTracing/pbrt/pbrt-v4/src/pbrt/bxdfs.cpp(765): here

I believe it's because MSVC doesn't support zero length array, which is ok for clang
using Warp2D0 = PiecewiseLinear2D<0>;
after changed <0> to <1>, it compiles, but maybe a template specialization is better I think

and also, add some #ifndef PBRT_IS_WINDOWS like you said

as for the RGB error,
just put

#pragma push_macro("RGB")
#undef RGB

at the front of spectrum.cpp, and
#pragma pop_macro("RGB")
at the end of spectrum.cpp

after all these, it compile, but with a lot link errors

2>libpbrt.lib(pbrt.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_000069f8_00000000_8_pbrt_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(log.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_38_tmpxft_00005f60_00000000_8_log_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(stats.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_00005e04_00000000_8_stats_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(pstd.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_00007d00_00000000_8_pstd_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(vecmath.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_42_tmpxft_000092c0_00000000_8_vecmath_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(sampling.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_43_tmpxft_000092b8_00000000_8_sampling_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(spectrum.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_43_tmpxft_00009b10_00000000_8_spectrum_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(transform.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_44_tmpxft_00009724_00000000_8_transform_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(scattering.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_45_tmpxft_00009314_00000000_8_scattering_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(bxdfs.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_000062b0_00000000_8_bxdfs_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(primes.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_41_tmpxft_00002fdc_00000000_8_primes_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(options.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_42_tmpxft_00006e18_00000000_8_options_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(filters.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_42_tmpxft_00007f3c_00000000_8_filters_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(color.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_000091e4_00000000_8_color_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(lights.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_41_tmpxft_00002914_00000000_8_lights_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(colorspace.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_45_tmpxft_0000940c_00000000_8_colorspace_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(math.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_00009314_00000000_8_math_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(mesh.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_00004c98_00000000_8_mesh_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(shapes.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_41_tmpxft_000092dc_00000000_8_shapes_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(lightsamplers.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_48_tmpxft_000093cc_00000000_8_lightsamplers_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(error.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_0000381c_00000000_8_error_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(samplers.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_43_tmpxft_00007f3c_00000000_8_samplers_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(sobolmatrices.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_48_tmpxft_00007754_00000000_8_sobolmatrices_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(bluenoise.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_44_tmpxft_00007288_00000000_8_bluenoise_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(pmj02tables.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_46_tmpxft_00009330_00000000_8_pmj02tables_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(film.cpp.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_00007dc0_00000000_8_film_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(cameras.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_42_tmpxft_00008f04_00000000_8_cameras_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(init.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_00009624_00000000_8_init_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(check.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_00006b30_00000000_8_check_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(interaction.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_46_tmpxft_000066c8_00000000_8_interaction_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(rng.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_38_tmpxft_00008f98_00000000_8_rng_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(lowdiscrepancy.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_49_tmpxft_000060a0_00000000_8_lowdiscrepancy_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(noise.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_00007f70_00000000_8_noise_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(textures.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_43_tmpxft_00008f04_00000000_8_textures_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(materials.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_44_tmpxft_00008ba8_00000000_8_materials_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)
2>libpbrt.lib(bssrdf.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_41_tmpxft_0000277c_00000000_8_bssrdf_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@YAXXZ)

I am not familiar with cuda, so not sure what to do next then...

The attached file is a patch, in case anyone need it
pbrt-v4_MSVC_compile_fix.diff.txt

mmp added a commit that referenced this issue Aug 28, 2020
Fixes via @wuyakuma in issue #20 (with some reformatting / minor changes.)
@jiangwei007
Copy link

@mmp
When pbrt_exe project linking, there are some link errors:
libpbrt.lib(pbrt.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_000069f8_00000000_8_pbrt_cpp1_ii_27c0afcc referenced in function "void __cdecl __sti____cudaRegisterAll(void)" (?__sti____cudaRegisterAll@@yaxxz)

@richardmgoodin
Copy link
Author

I've just compiled with your latest commit from scratch. The path where the zlib static library is found appears to be off. The library is built in build\src\ext\zlib\Debug\zlibstatic.lib. It is referenced as:

------ Build started: Project: wtest, Configuration: Debug x64 ------
LINK : fatal error LNK1104: cannot open file '......\zlib\Debug\zlibstatic_d.lib'
LINK : fatal error LNK1104: cannot open file '......\zlib\Debug\zlibstatic_d.lib'

I don't know enough about where the project is building to figure out the difference.

Here's another error (I'm also getting a lot of the "host function" warnings:

C:\cygwin64\home\goodin\pbrt-v4\src\pbrt/util/sampling.h(732): warning : calling a host function from a host device function is not allowed

C:\cygwin64\home\goodin\pbrt-v4\src\pbrt/util/pstd.h(86): error : incomplete type is not allowed

I'm not seeing any other explicit errors. I'm getting 13 failures total. Most seem to be related to not finding zlib.

mmp added a commit that referenced this issue Aug 28, 2020
Mostly to make MSVC happy, but it's got a point...
Relates to issue #20.
@mmp
Copy link
Owner

mmp commented Aug 28, 2020

(Status: I think that ToT includes all of the fixes that @wuyakuma listed, except for the shared libraries one.)

From a little googling, it looks like switching to shared libs is the cause of those missing __cudaRegisterLinkedBinary* symbols. In general, I've found it's best to avoid shared libs for pbrt, just because it's one more thing that can confuse students who are trying to use the system. In this case, when BUILD_SHARED_LIBS is set to ON, it also looks like the OpenEXR DLLs are going into a different directory than pbrt.exe, which makes it even more confusing. (So, my preference would be to figure out a non-shared lib approach, if that is possible.)

zlib and OpenEXR on windows have been a long-standing headache with the pbrt build. OpenEXR requires a zlib install, but we try to build it for the user if it isn't installed, just to make pbrt self-contained. An alternative could be to just require that people install zlib themselves; I'm wondering if that would take care of that zlibstatic issue you're seeing @richardmgoodin.

I'll take a look at those host/device function call warnings. There are a handful of them still on Linux, but they're all innocuous there.

Is there any more context on that "incomplete type" error?

@richardmgoodin
Copy link
Author

I'm good with the non shared library approach. I can't believe that anyone running pbrt would have problems with a larger executable. I'm also OK with installing zlib separately. I already have to do installs of CUDA and OptiX so one more wouldn't be an issue for the GPU version.

@richardmgoodin
Copy link
Author

Unfortunately I just did a recursive pull and got a new non building version of openEXR. This seems to be a consistent problem with their ToT in my very limited experience. That failure appears to be masking the others as I'm not seeing any other errors. Is there any way in Git I can pull a specific version of a recursive library?

@pierremoreau
Copy link
Contributor

pierremoreau commented Aug 28, 2020

An alternative could be to just require that people install zlib themselves

A third option could be using vcpkg (or Conan): it works on Windows, Linux and macOS, integrates with CMake, now has a manifest file (if you enable that feature on your computer, it will automatically download the listed dependencies before the rest of CMakeLists.txt runs), but it does not have versionning support yet (it might actually come in a month or two) so you end up with the latest packaged version (which could be enough for PBRT).

Is there any way in Git I can pull a specific version of a recursive library?

If you cd src/ext/openexr, you can just run a git checkout to whatever you want.

@mmp
Copy link
Owner

mmp commented Aug 28, 2020

@richardmgoodin ext/openexr should be at:

commit 5cfb5dab6dfada731586b0281bdb15ee75e26782 (HEAD -> zlibstatic-export-workaround, origin/zlibstatic-export-workaround)

(That was actually me forking ToT OpenEXR a week or two ago to fix a Windows build break related to zlib, so maybe your zlibstatic issues are due to having done a sync to a newer version?

@pierremoreau ah, interesting--good pointer. I'll look at those more closely. On one hand, I'm hoping that we're almost there and that it's just another small fix or two and everything will work, so I'd rather not make big changes to how the ext/ stuff is handled if necessary. On the other hand, that might be the best long-term option.

@richardmgoodin
Copy link
Author

Yes, that's the version I have. So I have been assuming that it was changes to OpenEXR that was breaking the build. I have also backed up to OpenEXR 2.3.5 which gives the same errors.

That was a long and twisty divergence. I just deleted and pulled a new version. Here is what I'm seeing it looks like I'm getting two blocks of errors. One linking and one having to do with RGB. Here's the linking problem. It looks like the function call parameters are getting munged.

34>libpbrt_d.lib(pbrt.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_00000a40_00000000_8_pbrt_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
33> Creating library C:/cygwin64/home/goodin/pbrt-v4/build/Debug/pbrt_test.lib and object C:/cygwin64/home/goodin/pbrt-v4/build/Debug/pbrt_test.exp
34>libpbrt_d.lib(log.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_38_tmpxft_000034a4_00000000_8_log_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(stats.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_000031a0_00000000_8_stats_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(error.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_0000421c_00000000_8_error_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(pathintegrator.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_49_tmpxft_00004988_00000000_8_pathintegrator_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(init.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_00002354_00000000_8_init_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(pstd.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_000042c4_00000000_8_pstd_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(color.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_00004ba0_00000000_8_color_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(spectrum.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_43_tmpxft_00004b84_00000000_8_spectrum_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(mesh.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_00001720_00000000_8_mesh_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(shapes.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_41_tmpxft_00001af4_00000000_8_shapes_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(colorspace.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_45_tmpxft_00003e20_00000000_8_colorspace_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(options.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_42_tmpxft_00001188_00000000_8_options_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(filters.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_42_tmpxft_00004bf8_00000000_8_filters_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(film.cpp.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_00004764_00000000_8_film_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(cameras.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_42_tmpxft_00003978_00000000_8_cameras_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(lights.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_41_tmpxft_000049dc_00000000_8_lights_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(samplers.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_43_tmpxft_00002c54_00000000_8_samplers_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(textures.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_43_tmpxft_00001ac4_00000000_8_textures_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(check.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_00004e2c_00000000_8_check_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(vecmath.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_42_tmpxft_000012d4_00000000_8_vecmath_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(math.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_00004504_00000000_8_math_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(transform.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_44_tmpxft_000041f4_00000000_8_transform_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(materials.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_44_tmpxft_000025f8_00000000_8_materials_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(lightsamplers.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_48_tmpxft_000032ac_00000000_8_lightsamplers_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(launch.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_41_tmpxft_00003df4_00000000_8_launch_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(camera.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_41_tmpxft_00001dd4_00000000_8_camera_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(samples.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_42_tmpxft_00003014_00000000_8_samples_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(media.cpp.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_00003dec_00000000_8_media_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(subsurface.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_45_tmpxft_000030dc_00000000_8_subsurface_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(surfscatter.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_46_tmpxft_00002b98_00000000_8_surfscatter_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(film.cpp.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_39_tmpxft_0000319c_00000000_8_film_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(accel.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_000032ac_00000000_8_accel_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(sampling.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_43_tmpxft_00004760_00000000_8_sampling_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(interaction.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_46_tmpxft_00004710_00000000_8_interaction_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(primes.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_41_tmpxft_000000fc_00000000_8_primes_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(rng.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_38_tmpxft_00001a1c_00000000_8_rng_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(lowdiscrepancy.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_49_tmpxft_00004c3c_00000000_8_lowdiscrepancy_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(pmj02tables.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_46_tmpxft_00002e70_00000000_8_pmj02tables_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(noise.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_00002064_00000000_8_noise_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(scattering.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_45_tmpxft_00001fc0_00000000_8_scattering_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(bxdfs.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_40_tmpxft_00003424_00000000_8_bxdfs_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(sobolmatrices.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_48_tmpxft_00002dac_00000000_8_sobolmatrices_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(bluenoise.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_44_tmpxft_00001fec_00000000_8_bluenoise_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>libpbrt_d.lib(bssrdf.obj) : error LNK2019: unresolved external symbol __cudaRegisterLinkedBinary_41_tmpxft_00001b10_00000000_8_bssrdf_cpp1_ii_27c0afcc referenced in function "void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)
34>C:\cygwin64\home\goodin\pbrt-v4\build\Debug\pbrt.exe : fatal error LNK1120: 45 unresolved externals

And the following (looks like RGB again):

32>C:\cygwin64\home\goodin\pbrt-v4\src\pbrt\cmd\imgtool.cpp(1042,50): error C2440: 'initializing': cannot convert from 'initializer list' to 'std::vector<pbrt::RGB,std::allocatorpbrt::RGB>'
32>C:\cygwin64\home\goodin\pbrt-v4\src\pbrt\cmd\imgtool.cpp(1171,1): message : No constructor could take the source type, or constructor overload resolution was ambiguous
32>C:\cygwin64\home\goodin\pbrt-v4\src\pbrt\cmd\imgtool.cpp(1217,51): error C2679: binary '=': no operator found which takes a right-hand operand of type 'COLORREF' (or there is no acceptable conversion)
32>C:\cygwin64\home\goodin\pbrt-v4\src\pbrt/util/color.h(147,1): message : could be 'pbrt::RGB &pbrt::RGB::operator =(pbrt::RGB &&)'
32>C:\cygwin64\home\goodin\pbrt-v4\src\pbrt/util/color.h(147,1): message : or 'pbrt::RGB &pbrt::RGB::operator =(const pbrt::RGB &)'
32>C:\cygwin64\home\goodin\pbrt-v4\src\pbrt\cmd\imgtool.cpp(1217,51): message : while trying to match the argument list '(pbrt::RGB, COLORREF)'
32>C:\cygwin64\home\goodin\pbrt-v4\src\pbrt\cmd\imgtool.cpp(1219,61): error C2679: binary '=': no operator found which takes a right-hand operand of type 'COLORREF' (or there is no acceptable conversion)
32>C:\cygwin64\home\goodin\pbrt-v4\src\pbrt/util/color.h(147,1): message : could be 'pbrt::RGB &pbrt::RGB::operator =(pbrt::RGB &&)'
32>C:\cygwin64\home\goodin\pbrt-v4\src\pbrt/util/color.h(147,1): message : or 'pbrt::RGB &pbrt::RGB::operator =(const pbrt::RGB &)'
32>C:\cygwin64\home\goodin\pbrt-v4\src\pbrt\cmd\imgtool.cpp(1219,61): message : while trying to match the argument list '(pbrt::RGB, COLORREF)'
32>C:\cygwin64\home\goodin\pbrt-v4\src\pbrt\cmd\imgtool.cpp(1222,27): warning C4244: 'initializing': conversion from 'pbrt::Float' to 'int', possible loss of data
32>C:\cygwin64\home\goodin\pbrt-v4\src\pbrt\cmd\imgtool.cpp(1223,73): warning C4267: 'argument': conversion from 'size_t' to 'const _Ty', possible loss of data

mmp added a commit that referenced this issue Aug 28, 2020
mmp added a commit that referenced this issue Aug 28, 2020
@mmp
Copy link
Owner

mmp commented Aug 28, 2020

Just pushed a fix for the imgtool one--thanks. (I have no idea where RGB is getting defined and why it's only on the Windows+NVCC build...)

Are those __cudaRegisterLinkedBinary errors with a clean TOT, or have you set BUILD_SHARED_LIBS to ON, as per @wuyakuma's suggestion?

@richardmgoodin
Copy link
Author

Those were with a clean ToT

@mmp
Copy link
Owner

mmp commented Aug 28, 2020

Ok, could you try adding:

set_property(TARGET pbrt_lib PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON)

Down around line 661 of the top-level CMakeLists.txt and rebuilding?

(Via https://stackoverflow.com/a/51566919, which reports that this is a Windows-only cmake bug, and it sure looks like the same symptoms...)

@richardmgoodin
Copy link
Author

I'm still seeing the the zlib static missing problem. This is on a clean tree. It also looks like you have a typo on you imgtool fix. Line 58 says "indef". If we can get zlib to link I think we are there. Do you want me to install zlib separately?

@richardmgoodin
Copy link
Author

38>Generating Code...
38>LINK : fatal error LNK1104: cannot open file 'src\ext\zlib\Debug\zlibstatic_d.lib'

It looks like it is looking in the src tree instead of the build directory

@richardmgoodin
Copy link
Author

Also when I look in the build tree I see zlibstatic.lib not zlibstatic_d.lib

@mmp
Copy link
Owner

mmp commented Aug 28, 2020

If you wouldn't mind installing zlib, I'd be interested to hear if that makes a difference. (I'm not sure what's going on with those issues about looking for the wrong thing in the wrong place!)

@richardmgoodin
Copy link
Author

I tried installing zlib but apparently Cmake didn't find it and it still built but didn't find zlib. The log was identical to the previous run. I'm going to try to download the source and try it that way. Where can I get the source, there appears to be multiple hits on zlib online.

@richardmgoodin
Copy link
Author

Here's a verbose log of the failure. Looks like it his failing at the same place as before.
log.zip

mmp added a commit that referenced this issue Aug 30, 2020
@mmp
Copy link
Owner

mmp commented Aug 30, 2020

Ah, good find on those missing synchronizations--sorry I missed those. Added now!

I was surprised that I only saw a ~7% slowdown when I added all those synchronizations to test their overhead on Linux. (So that San Miguel scene went from ~70s to render to ~75s. While that was on a 2080 GPU with RTX cores, most of the work isn't ray intersections, so I'd expect a GV100 to have really good performance--in the same ballpark.)

I suspect the issue gets back to lots of data being copied back and forth between CPU and GPU between kernel launches on Windows: CPU accesses something that lives on the GPU, it gets copied over, then a kernel is launched, and it has to be copied back (even though it wasn't modified.)

@richardmgoodin
Copy link
Author

richardmgoodin commented Aug 30, 2020 via email

@pierremoreau
Copy link
Contributor

@mmp This is indeed what I was getting at, but I should have explained it better rather than just quote the programming guide. I will try the updated version later today, and then do a comparison with Linux as I have a dual boot with Arch.

You might want to add to the code something like the following in src/pbrt/gpu/init.cpp, GPUInit() after the device selection, to fail hard and early if we find an unsupported configuration:

    int hasUnifiedAddressing;
    CUDA_CHECK(
        cudaDeviceGetAttribute(&hasUnifiedAddressing, cudaDevAttrUnifiedAddressing, device));
    if (!hasUnifiedAddressing) {
        LOG_FATAL("The selected device (%d) does not support unified addressing.", device);
    }

    // On Windows we perform additional synchronisation to work around the lack of
    // concurrent managed access as this is a platform-wide issue and even occurs for
    // hardware that does support it.
#if !defined(PBRT_IS_WINDOWS)
    int hasConcurrentManagedAccess;
    CUDA_CHECK(cudaDeviceGetAttribute(&hasConcurrentManagedAccess,
                                      cudaDevAttrConcurrentManagedAccess,
                                      device));
    if (!hasConcurrentManagedAccess) {
        LOG_FATAL("The selected device (%d) does not support concurrent managed access.",
                  device);
    }
#endif

@pierremoreau
Copy link
Contributor

@mmp I knew I was forgetting to reply to one of your comments… Regarding OpenEXR, I will open an issue on their side and ask if they can change their behaviour, but I don’t know what could be done in PBRT. Maybe delete the cache variable after dealing with OpenEXR? But on the other hand I did not run into any issues regarding it and zlib.
@richardmgoodin When you did your clean builds, did you ran into more issues regarding zlib?

@richardmgoodin
Copy link
Author

I did run into the problem early on but haven't seen it lately with fresh builds either Release or Debug.

mmp added a commit that referenced this issue Aug 30, 2020
…GPU is running kernels.

This should allow the Windows GPU build to run without synchronizing after
each kernel launch. However, it currently causes a ~15-25% slowdown on
Linux. (If this does in fact work well on Windows, then we'll see about fixing that before merging it into master...)

Issue #20...
@mmp
Copy link
Owner

mmp commented Aug 30, 2020

I believe I've figured out how to rewrite things without too much pain so that the CPU isn't accessing unified memory during rendering. I just pushed that in a branch, windows-gpu-rework, since it currently causes a 15-25% slowdown on Linux. However, if it works, performance on Windows should be much better. (I'll dig into that slowdown now to see what's going on.)

@jiangwei007
Copy link

I'm running Release build of windows-gpu-reworks branch, on GTX1070, the utilization rate of GPU is near < 2% always, Is there something wrong what i do

@pierremoreau
Copy link
Contributor

Utilisation rate is a lot lower for me today (though I did went through a complete re-install of Windows from scratch, so hard to say what is different); Rendering killeroo-gold.pbrt with the default settings on the GPU (RTX 2080 Ti) is taking about 2h, and if Task Manager is to be trusted, GPU usage is at about 0.2% (though it is also saying it is currently using my other GPU). I need to compare against Linux later, and try the new branch.

@mmp
Copy link
Owner

mmp commented Aug 30, 2020

Interesting... on Linux killeroo-gold renders for me in 13.8s on a RTX 2080. 13.8s / .002 = 6900s ~= 2 hours, so it looks like utilization is likely the entire problem here.

I don't have any good theories for what the cause might be though. Hmm.

@pierremoreau
Copy link
Contributor

I'll fire up Nsight Systems to have a look there; maybe perf should be tracked in a separate issue though.

@richardmgoodin
Copy link
Author

richardmgoodin commented Aug 30, 2020 via email

@pierremoreau
Copy link
Contributor

@richardmgoodin If you specify CUDACXX=path/to/nvcc as an environment variable before running CMake, does it find it? Otherwise try the solution from #23.

@richardmgoodin
Copy link
Author

richardmgoodin commented Aug 30, 2020 via email

@richardmgoodin
Copy link
Author

richardmgoodin commented Aug 30, 2020 via email

@pierremoreau
Copy link
Contributor

If you look at the output of nvcc --help for the nvcc you specified, does it include c++17 under the std option? Is it properly using a CUDA 11.0 install and not an earlier version?

@richardmgoodin
Copy link
Author

richardmgoodin commented Aug 30, 2020 via email

@olegded
Copy link

olegded commented Aug 30, 2020

@richardmgoodin You should update the PATH environment variable so nvcc v11 will be found before any other version. Then, in the same terminal run cmake (e.g. running cmake-gui in the same terminal should show you that all CUDA-related variables are automatically set to the right values at the first run)

export PATH=/usr/local/cuda/bin:$PATH #assuming /usr/local/cuda is where v11 is installed
which nvcc # should output  /usr/local/cuda/bin/nvcc
nvcc --version #should be v11

You could probably check the values of CUDA_TOOLKIT_INCLUDE (is /usr/local/cuda/include on my system) and CUDA_TOOLKIT_ROOT_DIR (is /usr/local/cuda) CMake variables.

Now, you should be able to compile it. At least, this is what I see on my end.

Oleg

@richardmgoodin
Copy link
Author

richardmgoodin commented Aug 30, 2020 via email

@richardmgoodin
Copy link
Author

Definitely something going on evil with Windows. sanmiguel ran for me in 166.6s under Linux

@olegded
Copy link

olegded commented Aug 30, 2020

There are couple of warnings under Linux as well. Different compilers could use different settings for this case, e.g. see gcc warning options, I guess it needs more investigation, e.g. are warnings generated for the pbrt code or CUDA stack, etc.?

@richardmgoodin
Copy link
Author

So I'm back on Windows after discovering that my GV100 wasn't really as slow as it was looking. I've built clean with the windows-gpu-reworks branch and it looks faster. I use an app called "OpenHardwareMonitor" and it shows usage as follows:
GPU Core 100%
GPU Frame Buffer 50%
GPU Video Engine 0%
GPU Bus Interface 15% (I assume from this low number shared memory isn't shown here)
GPU Memory 15%

If I was going to take a guess what could be going on is that the Windows driver is emulating shared memory by copying large blocks of memory up and down very frequently and thrashing the system. I'm not familiar with Nsight. Would it show this if it was happening?

Just historically, even with the old Release w/sync code I was seeing GPU core around 70-80%. I don't know @jiangwei007 is seeing I have never seen utilization that low. What sm level is the 1070?

San Miguel now runs in 1802.8 which is about 15% faster.

@richardmgoodin
Copy link
Author

I just fired up Nsight compute and am getting about a 3% SM utilization. I don't know if I have run long enough to get out of building the BVH structure.

@pierremoreau
Copy link
Contributor

(Just for info, I opened #24 to look into the performance on Windows.)

@mmp
Copy link
Owner

mmp commented Sep 1, 2020

Closing this one out as well; AFAIK we are now all good on this front.

@mmp mmp closed this as completed Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants