Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

CMake fixes for building ArrayFire oneAPI backend in windows #3610

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
Loading
from

Conversation

edwinsolisf
Copy link
Contributor

@edwinsolisf edwinsolisf commented Oct 1, 2024

Implement CMake changes to fix building oneAPI in Windows

Description

  • Is this a new feature or a bug fix?: fix
  • Why these changes are necessary: enable building oneapi in windows
  • New functions and their functionality: None
  • Can this PR be backported to older versions?: unsure
  • Future changes not implemented in this PR: possible fixes for using the Visual Studio Generator with the Intel Toolchains

Fixes: #3609

Changes:

  1. Made linking against MKL_SYCL Public in CMake only when building on Windows.
  2. Forced CMAKE_MSVC_RUNTIME_LIBRARY="" and added manually the correct MSVC Runtime Library compile flag
    (-MT/MD/MTd/MDd) for the icx when building oneAPI
  3. Forced to use the SYCL OpenCL library from oneAPI when building the oneAPI backend.

Consequences:

Using the Intel oneAPI DPC++ Compiler Reference as a baseline, the correct way to build the oneAPI backend in windows is as follows (using MSVC2022 and oneapi 2025 for example):

  1. Open command prompt (cmd.exe) or powershell.
  2. Initialize oneAPI's environment variables
    In command prompt use:
C:\Program Files (x86)\Intel\oneAPI\setvars.bat

In powershell use

cmd.exe "/K" '"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" && powershell'  
  1. Initialize Windows MSVC Compiler Environment Variables
    In command prompt use:
C:\Program Files\Microsoft Visual Studio\2022\Community\Auxiliary\Build\vcvars64.bat

In powershell use:

 cmd.exe "/K" '"C:\Program Files\Microsoft Visual Studio\2022\Community\Auxiliary\Build\vcvars64.bat" && powershell'  
  1. CMake configure project using the Ninja generator with the C and C++ compilers set to cl and the SYCL compiler set to icx:
cmake -B build -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_SYCL_COMPILER=icx -DAF_BUILD_ONEAPI=ON -G Ninja :: ... other options ...
  1. CMake build project like normal:
cmake --build build --target afoneapi -j 4

(From testing it seems that the icx compiler tends to use a lot of memory and crash if there are lots of jobs being executed. I recommend -j 4 for an 8-core machine specifically for building the afoneapi target. Furthermore, the linking step for afoneapi.lib takes a significant amount of time).

Changes to Users

  • Additional options added to the build: None
  • What changes will existing users have to make to their code or build steps?: Yes on windows: see Consequences above

Checklist

  • Rebased on latest master
  • Code compiles
  • Tests pass
  • Functions added to unified API
  • Functions documented

umar456
umar456 previously approved these changes Dec 17, 2024
@syurkevi syurkevi added this to the 3.10 milestone Feb 4, 2025
@christophe-murphy
Copy link
Contributor

This should be merged together with #3573

melonakos
melonakos previously approved these changes Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Build] Fix Build setup for oneAPI backend on Windows
5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.