Files
ispc/tests/lit-tests/stdlib-short-vec-funcs-3.ispc
T
Trung Lê b72df90271 Add Linux ppc64le (PowerPC64) architecture support using generic targets (#3735)
* Add Linux ppc64le (PowerPC64) architecture support using generic targets

Add ppc64le as a new architecture in ISPC, enabling compilation for
POWER8+ (POWER ISA 3.0) processors using the existing generic target
system (generic-i1x4 through generic-i64x4).

Key changes:
- Add Arch::ppc64le enum and parsing/serialization support
- Add CPU_PPC64LE_Generic device type with pwr8 baseline and +vsx features
- Initialize LLVM PowerPC backend when ISPC_PPC64_ENABLED is defined
- Generate ppc64le-linux-gnu triple for the target
- Auto-detect ppc64le host architecture and default to generic-i32x4
- Add PPC64_ENABLED CMake option (OFF by default) with powerpc LLVM component
- Add ppc64le support to builtin generation (GenerateBuiltins.cmake,
  GenericTargets.cmake, bitcode2cpp.py)
- Add PowerPC to LLVM_TARGETS_TO_BUILD in alloy.py and superbuild
- Add lit test infrastructure: PPC64_ENABLED feature flag, PPC64LE_HOST
  detection, and generic-target-ppc64le.ispc test
- Mark 5 tests UNSUPPORTED on PPC64LE_HOST due to known issues:
  gather/scatter assertion, LLVM selection failures, missing rcp stdlib,
  and ABI signext mismatch

Tested on Fedora 43 ppc64le (POWER8+) with LLVM 20: 425 tests passed,
267 unsupported, 3 expectedly failed, 0 failures.

* Add ppc64le to supported architectures in documentation

Update ispc.rst to list ppc64le in supported architectures and add
experimental PowerPC64 support entry to v1.31.0 release notes.

* Add ppc64le support to examples timing utility

Add __powerpc64__ to the architecture guard in timing.h so it uses
gettimeofday-based timing instead of x86 inline assembly (rdtsc/cpuid)
on PowerPC64 hosts.

* Add ppc64le support to example CMake build system

Add ppc64le architecture detection and generic target selection to the
example build system. On ppc64le, examples default to generic-i32x4
target. Also guard x86-specific -m32/-m64 compiler flags to only apply
on x86 architectures.

All 15 CPU examples build and pass on ppc64le.

* Fix generic-target build and ppc64le arch inference for cross-compilation

Fix missing build dependencies for the generic-target CMake OBJECT library:
- Add GENERATED property to generated CPP source files
- Add add_dependencies on generic-target-cpp and generic-stdlib-cpp targets
- Move configure_ispc_obj(generic-target) into add_ispc_slim() so include
  directories are set in both slim and composite binary paths

Fix lGetArchFromTarget to correctly infer ppc64le architecture when
cross-compiling with --cpu=ppc64le on non-PPC hosts. Previously the arch
inference was entirely host-guarded, causing it to fall through to x86_64.

* Address PR review: fix ppc64le triple, add test runner support and asm test

- Fix ppc64le LLVM triple to use canonical 'powerpc64le' prefix instead
  of 'ppc64le' in cmake/GenerateBuiltins.cmake
- Add ppc64le support to scripts/run_tests.py: target config, gcc_arch
  flags, and default target/arch detection for ppc64le hosts
- Add ppc64le-vector-asm.ispc lit test verifying PowerPC VSX vector
  instructions (xvaddsp, xvmulsp) are generated for generic targets

* Revert autoformatted changes

* Document reasons for ppc64le UNSUPPORTED test skips

Add explanatory comments to all lit tests marked UNSUPPORTED on ppc64le:
- stdlib-short-vec-funcs-3: LLVM 20 can't select froundeven for vectors
- stdlib-short-vec-funcs-6: LLVM 20 can't promote atan2/pow/fmod results
  Both are fixed in LLVM 21 (PR llvm/llvm-project#150597)
- fast_math_opt: generic target rcp uses fdiv, failing CHECK_NOFDIV
- num-limits: ABI mismatch for int8/int16 returns between ISPC and clang
- 2169: ISPC assertion in integer divide optimization for generic targets

* Make ppc64le LLVM bug test skips version-conditional

Use 'UNSUPPORTED: PPC64LE_HOST && !LLVM_21_0+' instead of unconditional
'UNSUPPORTED: PPC64LE_HOST' for tests that fail due to LLVM 20 PowerPC
backend bugs fixed in LLVM 21. This automatically re-enables the tests
when ISPC is built with LLVM 21+.

* s/UNSUPPORTED/XFAIL

* Add -mcpu

* Update docs

* Add PPC64 CI workflow with Ubuntu + QEMU for lit tests

* Fix check_isa to guard PPC64LE detection with endianness check

* Re-align with default target

* Revert all changes made to docs/ispc.rst

* Add functional tests to PPC64 CI workflow via QEMU

* Disable ispcrt build in PPC64 CI to avoid TBB dependency

* Install libtbb-dev instead of disabling ispcrt in PPC64 CI

* Disable X86 and ARM targets in PPC64 CI to avoid missing 32-bit headers

* Install gcc-multilib and re-enable all targets in PPC64 CI

* Install python3-dev for examples build in PPC64 CI

* Switch PPC64 CI to Ubuntu 25.10 with native LLVM 20 packages

* Fix LLVM tools package name to llvm-20-tools for Ubuntu 25.10

* Replace gcc-multilib with cross-compilation headers in PPC64 CI

Use libc6-dev-i386-cross and libc6-dev-armhf-cross instead of gcc-multilib
to provide 32-bit headers for builtin compilation. This avoids the package
conflict between gcc-multilib and gcc-powerpc64le-linux-gnu on Ubuntu 25.10.

* Add libstdc++-15-dev for host C++ linking in PPC64 CI

clang++ needs libstdc++-dev to link C++ programs on the host. Previously
gcc-multilib pulled this in as a dependency; now that we use cross packages
instead, we need to install it explicitly.

* Create FileCheck symlink for unversioned lookup in PPC64 CI

Ubuntu 25.10 installs FileCheck as FileCheck-20 (versioned), but ISPC's
CMake FindLLVM.cmake looks for the unversioned name. Create a symlink
to resolve this.

Tested locally: full build + lit tests pass in Ubuntu 25.10 Docker.

* Revert configure_ispc_obj(generic-target) move, no longer needed after #3739

* Fix PPC64 CI: build only PPC64 target, remove unnecessary cross-compilation packages

Disable ARM and x86 targets in the PPC64 CI workflow since they are
not needed and cause build failures due to missing cross-compilation
headers in the container. Also remove libc6-dev-i386-cross and
libc6-dev-armhf-cross packages that were only needed for those targets.

* Fix PPC64 CI: keep X86 enabled for host lit tests, remove build artifacts

Remove -DX86_ENABLED=OFF from the PPC64 CI cmake command since lit tests
use --target=host which detects x86 on the CI runner.

Remove set_source_files_properties and add_dependencies lines from
GenericTargets.cmake that were artifacts of the configure_ispc_obj move
reverted in c1a2b488.

* fix: Fix PPC64LE pipeline

* Add pipeline running on native runner

* Add sudo to apt-get install commands in workflow

* Consolidate pipelines

* Skip miscompiled float16 tests on ppc64le and fix native runner

- Add '// rule: skip on arch=ppc64le' to 54 float16/f16 functional tests
  that fail compilation on ppc64le
- Drop g++-multilib from native runner (unavailable on ppc64le)
- Add -DX86_ENABLED=OFF to native runner cmake to avoid x86 dependencies

* Refactor ppc64le arch inference out of lGetArchFromTarget

Revert lGetArchFromTarget to its original single-parameter signature and
move the cross-compilation arch fix-up for ppc64le to the call site.
This keeps the function focused on target-to-arch mapping and handles
the CPU-based override separately.

* Rename ppc64le CPU identifier to pwr8

Use 'pwr8' instead of 'ppc64le' as the CPU name for the generic PPC64LE
target, aligning the --cpu flag value with the actual LLVM CPU name that
was already being set internally.

* Skip float16 func tests on ppc64le due to missing fp16 support

* Install LLVM 19 packages for native ppc64le CI runner

* fix: clean up

* fix: install libclang-19-dev

* fix: s/generic/pwr8

* func-tests: skip round() varying float tests on ppc64le

LLVM PowerPC backend (POWER8) cannot lower @llvm.roundeven for vector
types (v4f32), which the generic builtin path uses for round(). Skip
these tests on ppc64le until a target-specific implementation is added.

* doc: clean up

* doc: move PowerPC support to new ISPC 1.31.0 section
2026-02-23 21:55:31 +00:00

55 lines
3.4 KiB
Plaintext

// This test just checks that the target math functions with short vectors are
// compiled without errors for all types and reasonable vector sizes.
// RUN: %{ispc} --target=host -o %t.o %s 2>&1
// LLVM 20 PowerPC backend can't select froundeven for vector types
// (Cannot select: v4f32 = froundeven). Fixed in LLVM 21 by PR #150597.
// XFAIL: PPC64LE_HOST && !LLVM_21_0+
#include <short_vec.isph>
#define VARYING(NAME, TYPE, N) \
varying TYPE<N> varying_##NAME(varying TYPE<N> a) { return NAME<TYPE, N>(a); }
#define UNIFORM(NAME, TYPE, N) \
uniform TYPE<N> uniform_##NAME(uniform TYPE<N> a) { return NAME<TYPE, N>(a); }
#define COMMON(NAME, TYPE, N) \
TYPE<N> common_##NAME(TYPE<N> a) { return NAME<TYPE, N>(a); }
#define VARYING_DED(NAME, TYPE, N) \
varying TYPE<N> varying_##NAME##_ded(varying TYPE<N> a) { return NAME(a); }
#define UNIFORM_DED(NAME, TYPE, N) \
uniform TYPE<N> uniform_##NAME##_ded(uniform TYPE<N> a) { return NAME(a); }
#define COMMON_DED(NAME, TYPE, N) \
TYPE<N> common_##NAME##_ded(TYPE<N> a) { return NAME(a); }
#define FUNC_TYPE_WIDTH(NAME, TYPE, N) \
COMMON(NAME, TYPE, N) \
COMMON_DED(NAME, TYPE, N) \
VARYING(NAME, TYPE, N) \
UNIFORM(NAME, TYPE, N) \
VARYING_DED(NAME, TYPE, N) \
UNIFORM_DED(NAME, TYPE, N)
#define FUNCS_WITH_DIFFERENT_WIDTHS(NAME, TYPE) \
FUNC_TYPE_WIDTH(NAME, TYPE, 1) \
FUNC_TYPE_WIDTH(NAME, TYPE, 2) \
FUNC_TYPE_WIDTH(NAME, TYPE, 3) \
FUNC_TYPE_WIDTH(NAME, TYPE, 4) \
FUNC_TYPE_WIDTH(NAME, TYPE, 8)
#define FUNCS_NAME(NAME) \
FUNCS_WITH_DIFFERENT_WIDTHS(NAME, float16) \
FUNCS_WITH_DIFFERENT_WIDTHS(NAME, float) \
FUNCS_WITH_DIFFERENT_WIDTHS(NAME, double)
FUNCS_NAME(round)
FUNCS_NAME(floor)
FUNCS_NAME(ceil)
FUNCS_NAME(trunc)
FUNCS_NAME(rcp)