Skip to content

Feature/win arm64 support - #3718

Open
nithin-aashik-mcw wants to merge 36 commits into
uxlfoundation:mainfrom
nithin-aashik-mcw:feature/win-arm64-support
Open

Feature/win arm64 support#3718
nithin-aashik-mcw wants to merge 36 commits into
uxlfoundation:mainfrom
nithin-aashik-mcw:feature/win-arm64-support

Conversation

@nithin-aashik-mcw

Copy link
Copy Markdown

Add Windows ARM64 (winarm) build support

Adds native build support for oneDAL on Windows ARM64 using clang/lld-link, extending the existing win32e (MSVC) and lnxarm targets.

Build system

  • New winarm platform target with clang/lld-link/llvm-lib toolchain (winarm.mk, clang.ref.arm.mk, arm.mk, lnxarm.mk, vc.mkl.32e.mk, common.mk)
  • Registered winarm in top-level PLATs; made Windows flags (-Fo, -Q, -EHsc, link rules) conditional on MSVC vs. clang
  • Fixed TBB/OpenBLAS path resolution to be per-architecture ($(_IA)) instead of hardcoded to intel64, in both makefile and deps.ref.mk
  • Wired OpenBLAS into the same release-copy machinery as TBB
  • Added VS2026 build tools support with arch-aware vcvarsall.bat (replacing x64-only vcvars64.bat)

Core / algorithm compatibility (clang-cl ≠ real MSVC)

  • Guarded _MSC_VER-only code paths with !defined(__clang__) across daal_defines.h, service_defines.h, service_topo.cpp, env_detect_features.cpp, KD-tree KNN kernel, and oneapi/dal/{backend,detail}/common.hpp
  • Added ARM64 Windows SVE feature detection via KUSER_SHARED_DATA
  • Switched to _aligned_malloc/_aligned_free on Windows instead of POSIX aligned_alloc/free

CI / tooling

  • build.bat / test.bat: detect host arch (AMD64/ARM64), set PLAT=winarm, propagate ARCH_DIR through TBB/OpenBLAS paths
  • Fixed robocopy bug in tbb.bat deleting source dirs after move
  • Fixed OpenBLAS archive path casing (OpenBlas-*OpenBLAS-*)
  • deploy/local/vars_win.bat: derive DAAL_IA from host arch instead of hardcoding intel64
  • examples/cmake/setup_examples.cmake / samples/cmake/setup_samples.cmake: recognize ARM64, fix intel_intel64intel64 naming

Testing

  • [✅] Built and ran examples/samples natively on Windows ARM64
  • [✅] CI passing on feature/win-arm64-support

@napetrov

Copy link
Copy Markdown
Contributor

@nithin-aashik-mcw - thanks - might be we would go straight to bazel build system?

@nithin-aashik-mcw

Copy link
Copy Markdown
Author

@napetrov Just to clarify, would you prefer that Windows ARM64 support be implemented in the Bazel build system instead?

@icfaust icfaust left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hoping someone with more build knowledge with me especially on the llvm/windows side of things can tell our status on that currently on x86, while this adds good CI/testing conformance for llvm+arm+win, the macros are not coded for arm, but for llvm+win.

Comment on lines +31 to +32
TBB_VERSION: v2023.1.0
OPENBLAS_VERSION: v0.3.33

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be added to renovate.json for proper tracking.

pull_request:
branches:
- main
- 'feature/**'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help me understand the addition of feature/**

Comment on lines +49 to +53
- name: Setup MSYS2
shell: pwsh
run: |
Invoke-WebRequest https://github.com/msys2/msys2-installer/releases/download/2026-06-11/msys2-${{ matrix.os.arch }}-20260611.exe -UseBasicParsing -OutFile msys2-${{ matrix.os.arch }}.exe
.\msys2-${{ matrix.os.arch }}.exe install --confirm-command --root "C:\msys64"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Msys2 provides a github action for this, I think we can trust them on that and would be lower maintenance (unless not available for this os/cpu combo?) let me know

- name: Install LLVM for Win-${{ matrix.os.arch }}
shell: pwsh
run: |
Invoke-WebRequest https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.8/LLVM-22.1.8-${{ matrix.os.llvm_arch }}.exe -UseBasicParsing -OutFile LLVM-${{ matrix.os.llvm_arch }}.exe

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way of installing llvm is likely to be high maintenance (hardcoded version in a url) is there any way to make this better for renovate tracking?

Start-Process msiexec.exe -ArgumentList "/i cmake-${{ matrix.os.arch }}.msi /quiet /norestart" -Wait
echo "C:\Program Files\CMake\bin" >> $env:GITHUB_PATH

Invoke-WebRequest https://github.com/ninja-build/ninja/releases/download/v1.13.2/ninja-win${{ matrix.os.arch }}.zip -OutFile ninja-win${{ matrix.os.arch }}.zip

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help explain the use of ninja

#ifdef __GNUC__
#define DAAL_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#elif defined(_MSC_VER) && !defined(__clang__)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should impact normal llvm builds on x86 using windows. Is this something we have checked what impact this may have?

Comment on lines +38 to +41
#elif defined(TARGET_ARM) && defined(_MSC_VER)
#define KUSER_SHARED_DATA_ADDR 0x7FFE0000UL
#define PROCESSOR_FEATURES_OFFSET 0x274
#define PF_ARM_SVE_INSTRUCTIONS_AVAILABLE 46

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs some code comments to make it more maintainable.

$$(if $$(CHECK_DLL_SIG),Wintrust.lib))
$$(eval daaldep.winarm.rt.dpc := $$(dep_dpc) \
$$(if $$(CHECK_DLL_SIG),Wintrust.lib))
$$(eval daaldep.win.threxport.create = grep -v -E '^(;|$$$$$$$$)' $$$$< $$$$(USECPUS.out.grep.filter))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is wild.

Comment thread .ci/env/openblas.bat
@@ -0,0 +1,84 @@
@echo off
rem ============================================================================
rem Copyright 2020 Intel Corporation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread .ci/env/openblas.bat

setlocal

rem req: PowerShell 3.0+

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't batch files meant to be runnable with the old Cmd.exe alone? Feels quite odd to launch powershell from a .bat file.

Comment thread .ci/env/openblas.bat
powershell.exe -command "if ($PSVersionTable.PSVersion.Major -lt 3) {Write-Host \"The script requires PowerShell 3.0 or above (current version: $($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor))\"; exit 1} else {exit 0}"
if errorlevel 1 goto Error_load

if /I not "%PROCESSOR_ARCHITECTURE%"=="ARM64" (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that cross-compilation is not supported?

- name: Checkout repository
uses: actions/checkout@v6

- name: Setup MSYS2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not be a problem to mix msys2 with LLVM-based tools? And does msys2 provide something that the LLVM stack doesn't?


/* oneDAL 64-bit integer types */
#if !(defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)) && defined(_MSC_VER)
#if !(defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)) && defined(_MSC_VER) && !defined(__clang__)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the CI is using clang-cl, not plain clang. Isn't that compiler supposed to provide the same headers with these kinds of definitions?

os: [
{ name: GitHub hosted, label: windows-11-vs2026-arm, cxx: clang, arch: arm64, isa: sve, llvm_arch: woa64 }
]
name: Windows-${{ matrix.os.arch }}-${{ matrix.os.cxx }}-${{ matrix.os.isa }}-${{ matrix.os.name }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall comment: would it be possible to build with conda-forge tooling as a separate job?
https://conda-forge.org/blog/2026/02/09/win-arm64/

static void * serv_malloc(size_t size, size_t alignment) { return aligned_alloc(alignment, size); }
static void * serv_malloc(size_t size, size_t alignment) {
#if defined(_MSC_VER)
return _aligned_malloc(size, alignment);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aligned_alloc is part of the C++17 standard:
https://en.cppreference.com/cpp/memory/c/aligned_alloc

Does MSVC or clang-cl not offer it?

#define PRAGMA_OMP_SIMD PRAGMA_TO_STR(omp simd)
#define PRAGMA_OMP_SIMD_ARGS(ARGS) PRAGMA_TO_STR_(omp simd ARGS)
#elif defined(_MSC_VER)
#elif defined(_MSC_VER) && !defined(__clang__)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in a series of elses that already checked for clang. It would have no effect.

-DDAAL_REF -DONEDAL_REF -DDAAL_CPU=sve -Werror -Wno-empty-body -Wreturn-type \
$(COMPILER.lnx.clang.target) \
$(COMPILER.sysroot)
COMPILER.win.clang= clang++ -march=armv8-a+sve \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, there is no requirement to support SVE in order to run windows on ARM.

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

Successfully merging this pull request may close these issues.

4 participants