How to build OSL OptiX support for Windows?

77 views
Skip to first unread message

FL Tariolle

unread,
Sep 26, 2019, 1:30:41 PM9/26/19
to OSL Developers
Hi,

Sorry for the previous topics with the same subject, an error occured with the server, and I finally found errors in my text.
Here is the final version.

I managed to build (and run) OSL master branch (1.11.1 dev in progress) with OptiX support for CentOS 7 with:

- OptiX 6.5
- CUDA 10.1
- LLVM 9.0.0

I can say we were early adopters of OSL OptiX support last year, and are glad with it on Linux, our primary platfom, but we have never succeeded to build it on Windows (except with USE_OPTIX=0, so without OptiX support)...

On Windows 7, I use Visual Studio 2017 compiler and compiling fails when LLVM CUDA bitcode macro starts using clang++...


This part of src\liboslexec\CMakeLists.txt rings a bell about MSVC issues.

if (USE_LLVM_BITCODE)
    LLVM_COMPILE
( llvm_ops.cpp liboslexec_srcs )

   
# Optionally repeat the bitcode compilation with CUDA-specific options
   
if (CUDA_FOUND)
        ADD_DEFINITIONS
(-DOSL_LLVM_CUDA_BITCODE)
        CUDA_SHADEOPS_COMPILE
( liboslexec_srcs )
    endif
()
else ()
    # With MSVC/Mingw, we don't compile llvm_ops.cpp to LLVM bitcode, due
   
# to clang being unable to compile MSVC C++ header files at this time.
   
# Instead it is part of the regular build process.

    ADD_DEFINITIONS
(-DOSL_LLVM_NO_BITCODE)
    SET
(liboslexec_srcs ${liboslexec_srcs} llvm_ops.cpp)
endif
()


How to build OSL with OptiX support for Windows, if USE_LLVM_BITCODE must be activated and does not work for MSVC?


Excerpt of src\cmake\externalpackages.cmake shows an error message when USE_LLVM_BITCODE is not set to 1:

###########################################################################
# OptiX setup

if (USE_OPTIX)
    find_package
(OptiX 5.0 REQUIRED)
    include_directories
(BEFORE "${OPTIX_INCLUDE_DIR}")

    if (NOT USE_LLVM_BITCODE OR NOT USE_FAST_MATH)
        message
(FATAL_ERROR "Enabling OptiX requires USE_LLVM_BITCODE=1 and USE_FAST_MATH=1")
    endif
()

endif ()

# end OptiX setup
###########################################################################


FYI, I generate VS2017 solution with this cmake command:

SET CUDA_TOOLKIT_ROOT_DIR=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1
SET OPTIXHOME
="C:/ProgramData/NVIDIA Corporation/OptiX SDK 6.5.0"


SET OSL_BUILD_SHADERS
=1
SET OSL_BUILD_MATERIALX
=0

SET LLVM_DIRECTORY
=%PATH_TO_LLVM_9_0_0%
SET LLVM_STATIC
=1
SET OPENEXR_ROOT_DIR
=%PATH_TO_OPENEXR_2_2_0%
SET ILMBASE_ROOT_DIR
=%PATH_TO_OPENEXR_2_2_0%
SET OPENIMAGEIO_ROOT_DIR
=%PATH_TO_OIIO_2_0_9%
SET BOOST_HOME
=%PATH_TO_BOOST_1_65_1%

SET USE_PARTIO
=0
SET USE_QT
=0

SET CUDA_ARCH
=52
SET CUDA_TARGET_ARCH
=sm_%CUDA_ARCH%
:: OptiX mandatory vars and values for OSL
SET USE_LLVM_BITCODE
=1
SET USE_FAST_MATH
=1
SET USE_OPTIX
=1

:: Init MY_CMAKE_FLAGS
SET MY_CMAKE_FLAGS
=

:: Append other flags to MY_CMAKE_FLAGS
SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DOSL_BUILD_SHADERS:BOOL=%OSL_BUILD_SHADERS%
SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DOSL_BUILD_MATERIALX:BOOL=%OSL_BUILD_MATERIALX%

SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DLLVM_DIRECTORY:STRING=%LLVM_DIRECTORY%
SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DLLVM_STATIC:BOOL=%LLVM_STATIC%

SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DOPENEXR_ROOT_DIR:STRING=%OPENEXR_ROOT_DIR%
SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DILMBASE_ROOT_DIR:STRING=%ILMBASE_ROOT_DIR%
SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DOPENIMAGEIO_ROOT_DIR:STRING=%OPENIMAGEIO_ROOT_DIR%
SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DBOOST_HOME:STRING=%BOOST_HOME%

SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DUSE_PARTIO:BOOL=%USE_PARTIO%
SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DUSE_QT:BOOL=%USE_QT%

SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DCUDA_ARCH:STRING=%CUDA_ARCH%
SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DCUDA_TARGET_ARCH:STRING=%CUDA_TARGET_ARCH%
SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DUSE_LLVM_BITCODE:BOOL=%USE_LLVM_BITCODE%
SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DUSE_FAST_MATH:BOOL=%USE_FAST_MATH%
SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DUSE_OPTIX:BOOL=%USE_OPTIX%
SET MY_CMAKE_FLAGS
=%MY_CMAKE_FLAGS% -DOPTIXHOME:STRING=%OPTIXHOME%

cd
%OSL_SOURCE_TREE%

cmake
-E make_directory %WIN64_OSL_INSTALL_OUTSIDE_ROOT_PATH%

cd
/D %WIN64_OSL_INSTALL_OUTSIDE_ROOT_PATH%

cmake
-G "Visual Studio 15 2017 Win64" -DVERBOSE:BOOL=1 -DCMAKE_INSTALL_PREFIX=%WIN64_OSL_INSTALL_RELEASE_PATH% %MY_CMAKE_FLAGS% -DBOOST_ROOT=%BOOST_HOME% %OSL_SOURCE_TREE%


Here are some error messages I get when building oslexec project for instance:


[..]

1>Generating opnoise_cuda.bc
1>In file included from opnoise.cpp:31:
1>In file included from D:/GitRepos/osl/src/liboslexec/oslexec_pvt.h:40:
1>In file included from D:/OslDeps/include/boost-1_65_1\boost/thread/tss.hpp:8:
1>In file included from D:/OslDeps/include/boost-1_65_1\boost/thread/detail/config.hpp:11:
1>In file included from D:/OslDeps/include/boost-1_65_1\boost/config.hpp:39:
1>D:/OslDeps/include/boost-1_65_1\boost/config/compiler/visualc.hpp(334,14): warning G4EB135E8: Unknown compiler version - please run the configure tests and report the results [-W#pragma-messages]
1># pragma message("Unknown compiler version - please run the configure tests and report the results")
1> ^
1>In file included from opnoise.cpp:31:
1>In file included from D:/GitRepos/osl/src/liboslexec/oslexec_pvt.h:40:
1>In file included from D:/OslDeps/include/boost-1_65_1\boost/thread/tss.hpp:8:
1>In file included from D:/OslDeps/include/boost-1_65_1\boost/thread/detail/config.hpp:13:
1>In file included from D:/OslDeps/include/boost-1_65_1\boost/thread/detail/platform.hpp:17:
1>D:/OslDeps/include/boost-1_65_1\boost/config/requires_threads.hpp(82,4): error G67F05DCB: "Compiler
 threading support is not turned on. Please set the correct command line
 options for threading: either /MT /MTd /MD or /MDd"

1>#
 error
"Compiler threading support is not turned on. Please set the
correct command line options for threading: either /MT /MTd /MD or /MDd"

1> ^
1>In file included from opnoise.cpp:31:
1>In file included from D:/GitRepos/osl/src/liboslexec/oslexec_pvt.h:40:
1>In file included from D:/OslDeps/include/boost-1_65_1\boost/thread/tss.hpp:8:
1>In file included from D:/OslDeps/include/boost-1_65_1\boost/thread/detail/config.hpp:465:
1>D:/OslDeps/include/boost-1_65_1\boost/config/auto_link.hpp(370,4): error G419390BC: "Mixing a dll boost library with a static runtime is a really bad idea..."
1># error "Mixing a dll boost library with a static runtime is a really bad idea..."
1> ^
1>D:/OslDeps/include/boost-1_65_1\boost/config/auto_link.hpp(408,4): error GB5FD6117: "some required macros where not defined (internal logic error)."
1># error "some required macros where not defined (internal logic error)."
1> ^

[..]

1>In file included from opnoise.cpp:31:
1>In file included from D:/GitRepos/osl/src/liboslexec/oslexec_pvt.h:44:
1>In file included from D:/GitRepos/osl/src/include\OSL/oslconfig.h:102:
1>In file included from D:/OslDeps/include\OpenImageIO/errorhandler.h:36:
1>In file included from D:/OslDeps/include\OpenImageIO/strutil.h:49:
1>In file included from D:/OslDeps/include\OpenImageIO/hash.h:49:
1>In file included from D:/OslDeps/include\OpenImageIO/span.h:18:
1>In file included from D:/OslDeps/include\OpenImageIO/dassert.h:37:
1>In file included from D:/OslDeps/include\OpenImageIO/platform.h:68:
1>In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\windows.h:165:
1>In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h:48:
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\synchapi.h(535,1): error G8BE29D73: conflicting types for 'CreateMutexA'
1>CreateMutexA(
1>^
1>D:/OslDeps/include/boost-1_65_1\boost/thread/win32/thread_primitives.hpp:173:55: note: previous declaration is here
1>                __declspec(dllimport) void* __stdcall CreateMutexA(_SECURITY_ATTRIBUTES*,int,char const*);
1>                                                      ^

[..)

1> ^
1>238 warnings and 10 errors generated when compiling for sm_52.
1>Done building project "oslexec.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========


They don't make sense to me, why clang acts like that on Windows only?

So I tried to fix this, but I think I may have taken the wrong way by adding ugly extra_clang_args to src\cmake\cuda_macros.cmake (see additional section in cmake code below).
This does not fix all errors, especially the one generated by windows headers: 

# Function to compile a C++ source file to CUDA-compatible LLVM bitcode
FUNCTION
( MAKE_CUDA_BITCODE src suffix generated_bc extra_clang_args )

[..]

    # NEW: inject additional clang extra args for Windows
   
if (WIN32 AND ${LLVM_BC_GENERATOR} MATCHES ".*clang.*")
       
# https://clang.llvm.org/docs/MSVCCompatibility.html
       
# https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions
       
set (extra_clang_args ${extra_clang_args} "-fms-extensions" "-fms-compatibility" "-fdelayed-template-parsing" "-fdeclspec" "-DBOOST_HAS_THREADS" "-D_DLL")

        MESSAGE
(STATUS "Using extra_clang_args = ${extra_clang_args} to generate bitcode.")
    endif
()

    ADD_CUSTOM_COMMAND (OUTPUT ${bc_cuda}
        COMMAND $
{LLVM_BC_GENERATOR}
           
"-I${OPTIX_INCLUDE_DIR}"


Did I miss something?

Any suggestion is welcome,

Thanks

FL Tariolle

unread,
Sep 27, 2019, 4:28:25 AM9/27/19
to OSL Developers
I have fixed 5 errors out of 10, and some warnings.

Warning "Unknown compiler version" is fixed by setting properly the toolset generator here with -G and -T cmake parameters (boost 1.65.1 does not support greater version of VC++ toolset) :

cmake -G "Visual Studio 15 2017" -A x64 -T v141,version=14.11,host=x64 -DVERBOSE:BOOL=1 -DCMAKE_INSTALL_PREFIX=%WIN64_OSL_INSTALL_RELEASE_PATH% %MY_CMAKE_FLAGS% -DBOOST_ROOT=%BOOST_HOME% %OSL_SOURCE_TREE%

Of course, you must be sure this toolset is properly installed as part of your Visual Studio 2017 setup.

To fix other boost releated errors, I changed my cuda_macros patch (described before), but I still don't know if it is the right way to follow:

set (extra_clang_args ${extra_clang_args} "-fms-extensions" "-fms-compatibility" "-fdelayed-template-parsing" "-fdeclspec" "-pthread" "-D_DLL")

Now, I only get 5 errors when building oslexec project, all related to windows headers:
                                                  ^
1>D:/OslDeps/include\OpenEXR/ImathExport.h:40:38: note: expanded from macro 'IMATH_EXPORT'
1>            #define IMATH_EXPORT __declspec(dllimport)

1>                                            ^
1>In file included from opnoise.cpp:31:
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\synchapi.h(590,1): error G8BE29D73: conflicting types for 'CreateEventA'
1>CreateEventA(
1>^
1>D:/OslDeps/include/boost-1_65_1\boost/thread/win32/thread_primitives.hpp:175:55: note: previous declaration is here
1>                __declspec(dllimport) void* __stdcall CreateEventA(_SECURITY_ATTRIBUTES*,int,int,char const*);

1>                                                      ^
1>In file included from opnoise.cpp:31:
1>In file included from D:/GitRepos/osl/src/liboslexec/oslexec_pvt.h:44:
1>In file included from D:/GitRepos/osl/src/include\OSL/oslconfig.h:102:
1>In file included from D:/OslDeps/include\OpenImageIO/errorhandler.h:36:
1>In file included from D:/OslDeps/include\OpenImageIO/strutil.h:49:
1>In file included from D:/OslDeps/include\OpenImageIO/hash.h:49:
1>In file included from D:/OslDeps/include\OpenImageIO/span.h:18:
1>In file included from D:/OslDeps/include\OpenImageIO/dassert.h:37:
1>In file included from D:/OslDeps/include\OpenImageIO/platform.h:68:
1>In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\windows.h:165:
1>In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h:58:
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\libloaderapi.h(276,1): error G6D63CA20: functions that differ only in their return type cannot be overloaded
1>GetModuleHandleA(
1>^
1>D:/OslDeps/include/boost-1_65_1\boost/thread/win32/thread_primitives.hpp:177:55: note: previous declaration is here
1>                __declspec(dllimport) void* __stdcall GetModuleHandleA(char const*);

1>                                                      ^
1>In file included from opnoise.cpp:31:
1>In file included from D:/GitRepos/osl/src/liboslexec/oslexec_pvt.h:44:
1>In file included from D:/GitRepos/osl/src/include\OSL/oslconfig.h:102:
1>In file included from D:/OslDeps/include\OpenImageIO/errorhandler.h:36:
1>In file included from D:/OslDeps/include\OpenImageIO/strutil.h:49:
1>In file included from D:/OslDeps/include\OpenImageIO/hash.h:49:
1>In file included from D:/OslDeps/include\OpenImageIO/span.h:18:
1>In file included from D:/OslDeps/include\OpenImageIO/dassert.h:37:
1>In file included from D:/OslDeps/include\OpenImageIO/platform.h:68:
1>In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\windows.h:165:
1>In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h:58:
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\libloaderapi.h(360,1): error G6D63CA20: functions that differ only in their return type cannot be overloaded
1>GetProcAddress(
1>^
1>D:/OslDeps/include/boost-1_65_1\boost/thread/win32/thread_primitives.hpp:197:59: note: previous declaration is here
1>                __declspec(dllimport) farproc_t __stdcall GetProcAddress(void *, const char *);

1>                                                          ^
1>In file included from opnoise.cpp:31:
1>In file included from D:/GitRepos/osl/src/liboslexec/oslexec_pvt.h:44:
1>In file included from D:/GitRepos/osl/src/include\OSL/oslconfig.h:102:
1>In file included from D:/OslDeps/include\OpenImageIO/errorhandler.h:36:
1>In file included from D:/OslDeps/include\OpenImageIO/strutil.h:49:
1>In file included from D:/OslDeps/include\OpenImageIO/hash.h:49:
1>In file included from D:/OslDeps/include\OpenImageIO/span.h:18:
1>In file included from D:/OslDeps/include\OpenImageIO/dassert.h:37:
1>In file included from D:/OslDeps/include\OpenImageIO/platform.h:68:
1>In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\windows.h:165:
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\winbase.h(3002,1): error G8BE29D73: conflicting types for 'CreateSemaphoreA'
1>CreateSemaphoreA(
1>^
1>D:/OslDeps/include/boost-1_65_1\boost/thread/win32/thread_primitives.hpp:174:55: note: previous declaration is here
1>                __declspec(dllimport) void* __stdcall CreateSemaphoreA(_SECURITY_ATTRIBUTES*,long,long,char const*);
1>                                                      ^

I'm still trying to find a way to fix this... but I wonder if clang can support windows headers in this case...

FL Tariolle

unread,
Sep 27, 2019, 12:09:22 PM9/27/19
to OSL Developers
Work in progress, but I wanted to share some improvements:

Even if "Compiling CUDA with clang" page is not up-to-date, CUDA compilation with clang on Windows (at least CUDA 9 with clang 9) should work now. The referenced clang bugfix has been resolved.

Using these extra_clang_args is better (I temporarily removed arguments which generate too much warnings or seem useless for the moment... I'll add them back afterwards)

set (extra_clang_args ${extra_clang_args} "-Wno-ignored-attributes" "-Wno-pragma-pack" "-DBOOST_USE_WINDOWS_H" "-pthread" "-D_DLL" "-DNOMINMAX")

BOOST_USE_WINDOWS_H solves my remaining Windows header failures, thanks to this github boost issue.

I finally fail in OpenImageIO 2.0.9 fmath.h OIIO::invert function (already patched to add the missing OIIO_HOSTDEVICE not released on RB-2.0 branch, available here).

The issue comes from fabs call when the template parameter is OSL::Dual<T,P>.

This template function exists in dual.h.

2>Generating opspline_cuda.bc
2>In file included from opspline.cpp:44:
2>In file included from D:/GitRepos/osl/src/liboslexec/oslexec_pvt.h:44:
2>In file included from D:/GitRepos/osl/src/include\OSL/oslconfig.h:102:
2>In file included from D:/OslDeps/include\OpenImageIO/errorhandler.h:36:
2>In file included from D:/OslDeps/include\OpenImageIO/strutil.h:49:
2>In file included from D:/OslDeps/include\OpenImageIO/hash.h:51:
2>D:/OslDeps/include\OpenImageIO/fmath.h(1891,9): error GEF7559A7: no matching function for call to 'fabs'
2>    if (fabs(v0-v1) < eps)   // already close enough
2>        ^~~~
2>D:/GitRepos/osl/src/liboslexec/splineimpl.h:283:23: note: in instantiation of function template specialization 'OpenImageIO_v2_0::invert<OSL_v1_11::Dual<float, 2>, OSL_v1_11::pvt::Spline::SplineInterp::SplineFunctor<OSL_v1_11::Dual<float, 2>, OSL_v1_11::Dual<float, 2> > >' requested here
2>            x = OIIO::invert (S, y, r0, r1, 32, YTYPE(1.0e-6), &brack);
2>                      ^
2>opspline.cpp:125:48: note: in instantiation of function template specialization 'OSL_v1_11::pvt::Spline::SplineInterp::inverse<OSL_v1_11::Dual<float, 2> >' requested here
2>  Spline::SplineInterp::create(HDSTR(spline_)).inverse<Dual2<float> >
2>                                               ^
2>D:/GitRepos/osl/src/include\OSL/dual.h:988:33: note: candidate function [with T = float, P = 2]
2>OSL_HOSTDEVICE inline Dual<T,P> fabs (const Dual<T,P> &x)
2>                                ^
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include\cmath:103:29: note: candidate function not viable: no known conversion from 'Dual<float, 2>' to 'float' for 1st argument
2>_Check_return_ inline float fabs(_In_ float _Xx) _NOEXCEPT
2>                            ^
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include\cmath:397:35: note: candidate function not viable: no known conversion from 'Dual<float, 2>' to 'long double' for 1st argument
2>_Check_return_ inline long double fabs(_In_ long double _Xx) _NOEXCEPT
2>                                  ^
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include\xtgmath.h:83:16: note: candidate function not viable: no known conversion from 'Dual<float, 2>' to 'double' for 1st argument
2>_GENERIC_MATH1(fabs, _CRT_JIT_INTRINSIC)
2>               ^
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include\xtgmath.h:39:18: note: expanded from macro '_GENERIC_MATH1'
2>        _GENERIC_MATH1R(FUN, double, CRTTYPE)
2>                        ^
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include\xtgmath.h:30:47: note: expanded from macro '_GENERIC_MATH1R'
2>extern "C" _Check_return_ CRTTYPE RET __cdecl FUN(_In_ double); \
2>                                              ^
2>D:\llvm-9.0.0-win.x64\lib\clang\9.0.0\include\__clang_cuda_device_functions.h:1487:19: note: candidate function not viable: no known conversion from 'Dual<float, 2>' to 'double' for 1st argument
2>__DEVICE__ double fabs(double __a) __NOEXCEPT { return __nv_fabs(__a); }
2>                  ^
2>D:\llvm-9.0.0-win.x64\lib\clang\9.0.0\include\__clang_cuda_cmath.h:67:18: note: candidate function not viable: no known conversion from 'Dual<float, 2>' to 'float' for 1st argument
2>__DEVICE__ float fabs(float __x) __NOEXCEPT { return ::fabsf(__x); }
2>                 ^
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include\xtgmath.h:83:16: note: candidate template ignored: requirement '::std::is_integral<OSL_v1_11::Dual<float, 2> >::value' was not satisfied [with _Ty = OSL_v1_11::Dual<float, 2>]
2>_GENERIC_MATH1(fabs, _CRT_JIT_INTRINSIC)
2>               ^
2>D:\llvm-9.0.0-win.x64\lib\clang\9.0.0\include\__clang_cuda_cmath.h:229:44: note: candidate template ignored: substitution failure [with __T = OSL_v1_11::Dual<float, 2>]: no type named 'type' in '__clang_cuda_enable_if<false, double>'
2>__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, fabs)
2>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
2>D:\llvm-9.0.0-win.x64\lib\clang\9.0.0\include\__clang_cuda_cmath.h:193:7: note: expanded from macro '__CUDA_CLANG_FN_INTEGER_OVERLOAD_1'
2>      __fn(__T __x) {                                                          \
2>      ^

I don't find any smart way to fix that, replacing fabs with T::fabs or fabs<T> does not work for 2 template instances of fmath OpenImageIO_v2_0::invert functions:
1 with float type,
1 with OSL_v1_11::Dual<float, 2> type

called by osl_splineinverse_fff and osl_splineinverse_dfdff of src\liboslexec\opspline.cpp

I know this problem is specific to windows version of clang.

Is it definitely a showstopper (meaning OSL OptiX support is not windows-ready yet),
or am I missing something meaning it should work now?

Larry Gritz

unread,
Sep 27, 2019, 1:47:03 PM9/27/19
to osl...@googlegroups.com
If you're trying to build master OSL with OptiX support, I would recommend also using the current top of tree OIIO master.
This is all experimental, fixes coming hot off the presses to the master branches as we go, not always backported to release branches.



--
You received this message because you are subscribed to the Google Groups "OSL Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osl-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osl-dev/ea2e2060-259f-44d6-a424-5cf4663c589b%40googlegroups.com.

--
Larry Gritz




FL Tariolle

unread,
Sep 30, 2019, 5:47:08 AM9/30/19
to OSL Developers
Thanks for the advice.

So now, I'm using OIIO master with OSL master, but it does not change anything regarding the Windows issues I described previously in this topic.

Larry Gritz

unread,
Sep 30, 2019, 6:22:26 PM9/30/19
to osl...@googlegroups.com
Are you sure you're building against current OIIO master? The error messages involving "invert" seems like exacttly the problem fixed by this recent(ish) PR: https://github.com/OpenImageIO/oiio/pull/2197

The fabs kind of rings a bell, too, but I haven't pinned it do a specific PR.
--
Larry Gritz




FL Tariolle

unread,
Oct 1, 2019, 1:21:18 AM10/1/19
to OSL Developers
Ok, may be I was not clear enough.

Yes I am building against latest commit of OIIO master (2.1.5.0 in progress)

The "OIIO_HOSTDEVICE invert" thing your're pointing at (PR #2197) is fixed.
In fact, it did not appear in build logs pasted in this topic with OIIIO 2.0.9, because I had already integrated this fix in my former OIIO 2.0.9 source tree.
I had just mentioned it to let the community knows OIIO 2.0.9 needs this PR to build OptiX support.

Now I'm building against OIIO master and the "fabs" issue still remains with clang 9 on Windows.

FL Tariolle

unread,
Oct 1, 2019, 4:11:11 AM10/1/19
to OSL Developers
By the way, as I understand Windows support with MSVC 2017 needs really latest tool and library versions, I am building with:

- MSVC 2017 latest toolset: v14.16
- CMake 3.15.3
- Boost 1.71.0

And as before :
- OIIO master (commit: PR #2350)
- OSL master (commit: PR #1062)

The errors with my cuda_macros.cmake patch for Windows (see previous posts) is:

2>In file included from opspline.cpp:44:
2>In file included from D:/GitRepos/osl/src/liboslexec/oslexec_pvt.h:44:
2>In file included from D:/GitRepos/osl/src/include\OSL/oslconfig.h:102:
2>In file included from D:/OslDeps/include\OpenImageIO/errorhandler.h:10:
2>In file included from D:/OslDeps/include\OpenImageIO/strutil.h:23:
2>In file included from D:/OslDeps/include\OpenImageIO/hash.h:25:
2>D:/OslDeps/include\OpenImageIO/fmath.h(2067,9): error GEF7559A7: no matching function for call to 'fabs'

2>    if (fabs(v0-v1) < eps)   // already close enough
2>        ^~~~
2>D:/GitRepos/osl/src/liboslexec/splineimpl.h:283:23: note: in instantiation of function template specialization 'OpenImageIO_v2_1::invert<OSL_v1_11::Dual<float, 2>, OSL_v1_11::pvt::Spline::SplineInterp::SplineFunctor<OSL_v1_11::Dual<float, 2>, OSL_v1_11::Dual<float, 2> > >' requested here
2>            x = OIIO::invert (S, y, r0, r1, 32, YTYPE(1.0e-6), &brack);
2>                      ^
2>opspline.cpp:125:48: note: in instantiation of function template specialization 'OSL_v1_11::pvt::Spline::SplineInterp::inverse<OSL_v1_11::Dual<float, 2> >' requested here
2>  Spline::SplineInterp::create(HDSTR(spline_)).inverse<Dual2<float> >
2>                                               ^
2>D:/GitRepos/osl/src/include\OSL/dual.h:988:33: note: candidate function [with T = float, P = 2]
2>OSL_HOSTDEVICE inline Dual<T,P> fabs (const Dual<T,P> &x)
2>                                ^
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\cmath:111:29: note: candidate function not viable: no known conversion from 'Dual<float, 2>' to 'float' for 1st argument
2>_Check_return_ inline float fabs(_In_ float _Xx) noexcept
2>                            ^
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\cmath:405:35: note: candidate function not viable: no known conversion from 'Dual<float, 2>' to 'long double' for 1st argument
2>_Check_return_ inline long double fabs(_In_ long double _Xx) noexcept
2>                                  ^
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\xtgmath.h:85:16: note: candidate function not viable: no known conversion from 'Dual<float, 2>' to 'double' for 1st argument
2>_GENERIC_MATH1(fabs, _CRT_JIT_INTRINSIC)
2>               ^
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\xtgmath.h:41:18: note: expanded from macro '_GENERIC_MATH1'

2>        _GENERIC_MATH1R(FUN, double, CRTTYPE)
2>                        ^
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\xtgmath.h:32:47: note: expanded from macro '_GENERIC_MATH1R'

2>extern "C" _Check_return_ CRTTYPE RET __cdecl FUN(_In_ double); \
2>                                              ^
2>D:\llvm-9.0.0-win.x64\lib\clang\9.0.0\include\__clang_cuda_device_functions.h:1487:19: note: candidate function not viable: no known conversion from 'Dual<float, 2>' to 'double' for 1st argument
2>__DEVICE__ double fabs(double __a) __NOEXCEPT { return __nv_fabs(__a); }
2>                  ^
2>D:\llvm-9.0.0-win.x64\lib\clang\9.0.0\include\__clang_cuda_cmath.h:67:18: note: candidate function not viable: no known conversion from 'Dual<float, 2>' to 'float' for 1st argument
2>__DEVICE__ float fabs(float __x) __NOEXCEPT { return ::fabsf(__x); }
2>                 ^
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\xtgmath.h:85:16: note: candidate template ignored: requirement '::std::is_integral_v<OSL_v1_11::Dual<float, 2> >' was not satisfied [with _Ty = OSL_v1_11::Dual<float, 2>]

2>_GENERIC_MATH1(fabs, _CRT_JIT_INTRINSIC)
2>               ^
2>D:\llvm-9.0.0-win.x64\lib\clang\9.0.0\include\__clang_cuda_cmath.h:229:44: note: candidate template ignored: substitution failure [with __T = OSL_v1_11::Dual<float, 2>]: no type named 'type' in '__clang_cuda_enable_if<false, double>'
2>__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, fabs)
2>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
2>D:\llvm-9.0.0-win.x64\lib\clang\9.0.0\include\__clang_cuda_cmath.h:193:7: note: expanded from macro '__CUDA_CLANG_FN_INTEGER_OVERLOAD_1'
2>      __fn(__T __x) {                                                          \
2>      ^

Reply all
Reply to author
Forward
0 new messages