codeplaysoftware / syclacademy

SYCL Academy, a set of learning materials for SYCL heterogeneous programming
https://sycl.tech
Creative Commons Attribution Share Alike 4.0 International
454 stars 102 forks source link

cmake build failed - icpx: error: unknown argument: '-MDd' #334

Open SailingDreams opened 8 months ago

SailingDreams commented 8 months ago

2024 oneAPI Windows 10 vscode terminal

I followed the readme.md instructions to install Installing DPC++ ("To set up DPC++ follow the getting started instructions.") and was able to build the simple-add example in https://github.com/oneapi-src/oneAPI-samples. But when I try to use the same steps to cmake build syclacademy, I get the following cmake error (the attached file has the cmake output when using cmake --trace).

The command I used to setup my environment in powershell is
cmd.exe "/K" '"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" && powershell'

I am using the generator option -G "NMake Makefiles" as per the readme in oneAPI-samples repo's simple-add example.

CmakeTraceOutput.txt

**Powershell output (without --trace) **** PS C:\git\oneAPI\syclacademy\build> cmake -G "NMake Makefiles" -DSYCL_ACADEMY_USE_DPCPP=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx ..
-- The CXX compiler identification is IntelLLVM 2024.0.2 with GNU-like command-line -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - failed -- Check for working CXX compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/icpx.exe -- Check for working CXX compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/icpx.exe - broken CMake Error at C:/Program Files/CMake/share/cmake-3.27/Modules/CMakeTestCXXCompiler.cmake:60 (message): The C++ compiler C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/icpx.exe is not able to compile a simple test program.

It fails with the following output:

Change Dir: 'C:/git/oneAPI/syclacademy/build/CMakeFiles/CMakeScratch/TryCompile-k4ywfh'

Run Build Command(s): "C:/Program Files/CMake/bin/cmake.exe" -E env VERBOSE=1 nmake -f Makefile /nologo cmTC_41f69\fast
    "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64\nmake.exe"  -f CMakeFiles\cmTC_41f69.dir\build.make /nologo -L                  CMakeFiles\cmTC_41f69.dir\build
Building CXX object CMakeFiles/cmTC_41f69.dir/testCXXCompiler.cxx.obj
    C:\PROGRA~2\Intel\oneAPI\compiler\latest\bin\icpx.exe @C:\Users\EDDIE~1.PAT\AppData\Local\Temp\nmF40C.tmp
icpx: error: unknown argument: '-MDd'
icpx: error: unknown argument: '-Zi'
icpx: error: no such file or directory: '/nologo'
icpx: error: no such file or directory: '/TP'
icpx: error: no such file or directory: '/DWIN32'
icpx: error: no such file or directory: '/D_WINDOWS'
icpx: error: no such file or directory: '/EHsc'
icpx: error: no such file or directory: '/Ob0'
icpx: error: no such file or directory: '/Od'
icpx: error: no such file or directory: '/RTC1'
icpx: error: no such file or directory: '/FoCMakeFilescmTC_41f69.dirtestCXXCompiler.cxx.obj'
icpx: error: no such file or directory: '/FdCMakeFilescmTC_41f69.dir -c'
icpx: error: no such file or directory: 'C:gitoneAPIsyclacademybuildCMakeFilesCMakeScratchTryCompile-k4ywfhtestCXXCompiler.cxx'
icpx: error: no input files
NMAKE : fatal error U1077: 'C:\PROGRA~2\Intel\oneAPI\compiler\latest\bin\icpx.exe @C:\Users\EDDIE~1.PAT\AppData\Local\Temp\nmF40C.tmp' : return code '0x1'        
Stop.

9.dir\build.make /nologo -L CMakeFiles\cmTC_41f69.dir\build' : return code '0x2' Stop. CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:23 (project) -- Configuring incomplete, errors occurred!

SailingDreams commented 8 months ago

I deleted the build directory and tried the following cmake command using -G"Visual Studio 17 2022" -A"x64" instead of -G "NMake Makefiles" , but got the error below:

_IntelSYCLFOUND to FALSE so package "IntelSYCL" is considered to be NOT FOUND

According to the header in IntelSYCLConfig.cmake, IntelSYCL_FOUND = TRUE when "the system has the SYCL library". So obviously I don't have the lib. But, isn't installing the oneAPI Base Toolkit not the same as installing said libraries?

syclacademy\build> cmake -G"Visual Studio 17 2022" -A"x64" -DSYCL_ACADEMY_USE_DPCPP=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx .. -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045. -- The C compiler identification is MSVC 19.37.32824.0 -- The CXX compiler identification is MSVC 19.37.32824.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - not found -- Found Threads: TRUE
CMake Error at CMakeLists.txt:67 (find_package): Found package configuration file:

C:/Program Files (x86)/Intel/oneAPI/compiler/2024.0/lib/cmake/IntelSYCL/IntelSYCLConfig.cmake

but it set IntelSYCL_FOUND to FALSE so package "IntelSYCL" is considered to be NOT FOUND. Reason given by package:

Unsupported compiler family MSVC and compiler C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe!!

-- Configuring incomplete, errors occurred!

SailingDreams commented 8 months ago

I also tried MSVC 2019. Same "IntelSYCL_FOUND to FALSE" error

build> cmake -G"Visual Studio 16 2019" -A"x64" -DSYCL_ACADEMY_USE_DPCPP=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx .. -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045. -- The C compiler identification is MSVC 19.29.30152.0 -- The CXX compiler identification is MSVC 19.29.30152.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - not found -- Found Threads: TRUE
CMake Error at CMakeLists.txt:67 (find_package): Found package configuration file:

C:/Program Files (x86)/Intel/oneAPI/compiler/latest/lib/cmake/IntelSYCL/IntelSYCLConfig.cmake

but it set IntelSYCL_FOUND to FALSE so package "IntelSYCL" is considered to be NOT FOUND. Reason given by package:

Unsupported compiler family MSVC and compiler C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe!! -- Configuring incomplete, errors occurred!

DuncanMcBain commented 8 months ago

Hi @SailingDreams,

I believe if you try to set the compiler as icl.exe for both the C and CXX compilers, as well as use the NMake option, that should work, though I don't have a Windows install to hand to the moment to test. I believe in the first attempt you made it thinks that it is running on a GNU-like system so gets confused. It appears that when you select the generator types as Visual Studio, it is forcing the use of cl.exe (i.e. Microsoft's compiler), which will definitely fail to configure.

SailingDreams commented 8 months ago

Thanks for getting back to me. I do not have icl.exe, but this allowed cmake to build - I changed the CXX compiler from icpx to icx. syclacademy\build> cmake -G"NMake Makefiles" -DSYCL_ACADEMY_USE_DPCPP=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icx ..

The output is below

-- The C compiler identification is IntelLLVM 2024.0.2 with MSVC-like command-line -- The CXX compiler identification is IntelLLVM 2024.0.2 with MSVC-like command-line -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/icx.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/icx.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - not found -- Found Threads: TRUE
-- Found IntelSYCL: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/include (found version "202001") -- Configuring done (13.6s) -- Generating done (0.8s) -- Build files have been written to: C:/git/oneAPI/syclacademy/build

SailingDreams commented 8 months ago

Bilding the project was successful. I used nmake

build> nmake

Microsoft (R) Program Maintenance Utility Version 14.37.32824.0 Copyright (C) Microsoft Corporation. All rights reserved.

[ 2%] Building CXX object Code_Exercises/Exercise_01_Compiling_with_SYCL/CMakeFiles/exercise_1_source.dir/source.cpp.obj [ 5%] Linking CXX executable exercise_1_source.exe [ 5%] Built target exercise_1_source [ 7%] Building CXX object Code_Exercises/Exercise_02_Hello_World/CMakeFiles/exercise_2_source.dir/source.cpp.obj [ 10%] Linking CXX executable exercise_2_source.exe [ 10%] Built target exercise_2_source [ 13%] Building CXX object Code_Exercises/Exercise_03_Scalar_Add/CMakeFiles/exercise_3_source.dir/source.cpp.obj [ 15%] Linking CXX executable exercise_3_source.exe [ 15%] Built target exercise_3_source [ 18%] Building CXX object Code_Exercises/Exercise_04_Handling_Errors/CMakeFiles/exercise_4_source.dir/source.cpp.obj [ 21%] Linking CXX executable exercise_4_source.exe [ 21%] Built target exercise_4_source [ 23%] Building CXX object Code_Exercises/Exercise_05_Device_Selection/CMakeFiles/exercise_5_source.dir/source.cpp.obj [ 26%] Linking CXX executable exercise_5_source.exe [ 26%] Built target exercise_5_source [ 28%] Building CXX object Code_Exercises/Exercise_06_Vector_Add/CMakeFiles/exercise_6_source.dir/source.cpp.obj [ 31%] Linking CXX executable exercise_6_source.exe [ 31%] Built target exercise_6_source [ 34%] Building CXX object Code_Exercises/Exercise_07_USM_Selector/CMakeFiles/exercise_7_source.dir/source.cpp.obj [ 36%] Linking CXX executable exercise_7_source.exe [ 36%] Built target exercise_7_source [ 39%] Building CXX object Code_Exercises/Exercise_08_USM_Vector_Add/CMakeFiles/exercise_8_source.dir/source.cpp.obj [ 42%] Linking CXX executable exercise_8_source.exe [ 42%] Built target exercise_8_source [ 44%] Building CXX object Code_Exercises/Exercise_09_Synchronization/CMakeFiles/exercise_9_source.dir/source.cpp.obj [ 47%] Linking CXX executable exercise_9_source.exe [ 47%] Built target exercise_9_source [ 50%] Building CXX object Code_Exercises/Exercise_10_Managing_Dependencies/CMakeFiles/exercise_10_source.dir/source.cpp.obj [ 52%] Linking CXX executable exercise_10_source.exe [ 52%] Built target exercise_10_source [ 55%] Building CXX object Code_Exercises/Exercise_11_In_Order_Queue/CMakeFiles/exercise_11_source.dir/source.cpp.obj [ 57%] Linking CXX executable exercise_11_source.exe [ 57%] Built target exercise_11_source [ 60%] Building CXX object Code_Exercises/Exercise_12_Temporary_Data/CMakeFiles/exercise_12_source.dir/source.cpp.obj [ 63%] Linking CXX executable exercise_12_source.exe [ 63%] Built target exercise_12_source [ 65%] Building CXX object Code_Exercises/Exercise_13_Load_Balancing/CMakeFiles/exercise_13_source.dir/source.cpp.obj [ 68%] Linking CXX executable exercise_13_source.exe [ 68%] Built target exercise_13_source [ 71%] Building CXX object Code_Exercises/Exercise_14_ND_Range_Kernel/CMakeFiles/exercise_14_source.dir/source.cpp.obj [ 73%] Linking CXX executable exercise_14_source.exe [ 73%] Built target exercise_14_source [ 76%] Building CXX object Code_Exercises/Exercise_15_Image_Convolution/CMakeFiles/exercise_15_reference.dir/reference.cpp.obj [ 78%] Built target exercise_15_reference [ 81%] Building CXX object Code_Exercises/Exercise_16_Coalesced_Global_Memory/CMakeFiles/exercise_16_source.dir/source.cpp.obj [ 84%] Linking CXX executable exercise_16_source.exe [ 84%] Built target exercise_16_source [ 86%] Building CXX object Code_Exercises/Exercise_17_Vectors/CMakeFiles/exercise_17_source.dir/source.cpp.obj [ 89%] Linking CXX executable exercise_17_source.exe [ 89%] Built target exercise_17_source [ 92%] Building CXX object Code_Exercises/Exercise_18_Local_Memory_Tiling/CMakeFiles/exercise_18_source.dir/source.cpp.obj [ 94%] Linking CXX executable exercise_18_source.exe [ 94%] Built target exercise_18_source [ 97%] Building CXX object Code_Exercises/Exercise_19_Work_Group_Sizes/CMakeFiles/exercise_19_source.dir/source.cpp.obj [100%] Linking CXX executable exercise_19_source.exe [100%] Built target exercise_19_source

DuncanMcBain commented 8 months ago

Great, I'm glad it's working!