Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Continuous integration tests a variety of platforms and configurations but it ge
* OS X XCode 15+: ARM64
* Emscripten 1.39.11: WASM

RISC-V/riscv64 currently uses the generic scalar path and does not enable SSE/AVX/NEON intrinsics. Native `make.py -cpu riscv64` builds are supported on Linux `riscv64` hosts; cross-compilation should be performed with CMake and a proper RISC-V toolchain file.

Each releases is also manually tested on iOS and Android.

## Getting started
Expand Down
6 changes: 6 additions & 0 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ In order to contribute to RTM you will first need to setup your environment.

On all three platforms, *AVX* support can be enabled by using the `-avx` switch and *AVX2* with `-avx2`. Intrinsic usage can be turned off with `-nosimd`.

### Linux riscv64

For native *Linux on riscv64*, the steps are identical to *x86 and x64* and the generic scalar path is selected automatically. You can generate build files with: `python make.py -cpu riscv64`

Cross-compilation to `riscv64` is not handled by `make.py`. Use CMake directly with a proper RISC-V compiler and toolchain file instead.

### Windows ARM64

For *Windows on ARM64*, the steps are identical to *x86 and x64* but you will need *CMake 3.13 or higher* and you must provide the architecture on the command line: `python make.py -compiler vs2017 -cpu arm64`
Expand Down
9 changes: 9 additions & 0 deletions includes/rtm/impl/detect_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
#define RTM_ARCH_ARM64
#elif defined(_M_ARM) || defined(__ARM_NEON)
#define RTM_ARCH_ARM
#elif defined(__riscv)
#define RTM_ARCH_RISCV
#if defined(__riscv_xlen) && (__riscv_xlen == 64)
#define RTM_ARCH_RISCV64
#elif defined(__riscv_xlen) && (__riscv_xlen == 32)
#define RTM_ARCH_RISCV32
Comment thread
nfrechette marked this conversation as resolved.
#else
#error Unsupported bit width
#endif
#elif defined(_M_X64) || defined(__x86_64__)
#define RTM_ARCH_X64
#elif defined(_M_IX86) || defined(__i386__)
Expand Down
44 changes: 23 additions & 21 deletions includes/rtm/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,29 @@
//////////////////////////////////////////////////////////////////////////

#if !defined(RTM_NO_INTRINSICS)
#if defined(__AVX2__)
#define RTM_AVX2_INTRINSICS
#define RTM_FMA_INTRINSICS
#define RTM_AVX_INTRINSICS
#define RTM_SSE4_INTRINSICS
#define RTM_SSE3_INTRINSICS
#define RTM_SSE2_INTRINSICS
#elif defined(__AVX__)
#define RTM_AVX_INTRINSICS
#define RTM_SSE4_INTRINSICS
#define RTM_SSE3_INTRINSICS
#define RTM_SSE2_INTRINSICS
#elif defined(__SSE4_1__)
#define RTM_SSE4_INTRINSICS
#define RTM_SSE3_INTRINSICS
#define RTM_SSE2_INTRINSICS
#elif defined(__SSSE3__)
#define RTM_SSE3_INTRINSICS
#define RTM_SSE2_INTRINSICS
#elif defined(__SSE2__) || defined(RTM_ARCH_X86) || defined(RTM_ARCH_X64)
#define RTM_SSE2_INTRINSICS
#if defined(RTM_ARCH_X86) || defined(RTM_ARCH_X64)
#if defined(__AVX2__)
#define RTM_AVX2_INTRINSICS
#define RTM_FMA_INTRINSICS
#define RTM_AVX_INTRINSICS
#define RTM_SSE4_INTRINSICS
#define RTM_SSE3_INTRINSICS
#define RTM_SSE2_INTRINSICS
#elif defined(__AVX__)
#define RTM_AVX_INTRINSICS
#define RTM_SSE4_INTRINSICS
#define RTM_SSE3_INTRINSICS
#define RTM_SSE2_INTRINSICS
#elif defined(__SSE4_1__)
#define RTM_SSE4_INTRINSICS
#define RTM_SSE3_INTRINSICS
#define RTM_SSE2_INTRINSICS
#elif defined(__SSSE3__)
#define RTM_SSE3_INTRINSICS
#define RTM_SSE2_INTRINSICS
#else
#define RTM_SSE2_INTRINSICS
#endif
#endif

#if defined(RTM_ARCH_ARM64)
Expand Down
23 changes: 16 additions & 7 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
import subprocess
import sys

def is_arm64_host():
return platform.machine() == 'arm64' or platform.machine() == 'aarch64'

def is_riscv64_host():
return platform.machine() == 'riscv64'

def parse_argv():
parser = argparse.ArgumentParser(add_help=False)

Expand All @@ -21,7 +27,7 @@ def parse_argv():
target = parser.add_argument_group(title='Target')
target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'vs2022', 'vs2022-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'clang12', 'clang13', 'clang14', 'clang15', 'clang16', 'clang17', 'clang18', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'gcc11', 'gcc12', 'gcc13', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler')
target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize)
target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'arm64ec', 'wasm'], help='Defaults to the host system\'s architecture')
target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'arm64ec', 'riscv64', 'wasm'], help='Defaults to the host system\'s architecture')
target.add_argument('-cpp_version', choices=['11', '14', '17', '20'], help='Defaults to C++11')

misc = parser.add_argument_group(title='Miscellaneous')
Expand All @@ -47,9 +53,8 @@ def parse_argv():

args = parser.parse_args()

is_arm64_cpu = False
if platform.machine() == 'arm64' or platform.machine() == 'aarch64':
is_arm64_cpu = True
is_arm64_cpu = is_arm64_host()
is_riscv64_cpu = is_riscv64_host()

# Sanitize and validate our options
if (args.use_avx or args.use_avx2) and not args.use_simd:
Expand Down Expand Up @@ -110,6 +115,8 @@ def parse_argv():
if not args.cpu:
if is_arm64_cpu:
args.cpu = 'arm64'
elif is_riscv64_cpu:
args.cpu = 'riscv64'
else:
args.cpu = 'x64'

Expand Down Expand Up @@ -137,6 +144,10 @@ def parse_argv():
if not args.compiler == 'android':
print('armv7 is only supported with Android')
sys.exit(1)
elif args.cpu == 'riscv64':
if not platform.system() == 'Linux' or not is_riscv64_cpu:
print('riscv64 is only supported natively on Linux hosts with a riscv64 compiler target; use CMake directly with a proper toolchain file for cross-compilation')
sys.exit(1)
elif args.cpu == 'wasm':
if not args.compiler == 'emscripten':
print('wasm is only supported with Emscripten')
Expand Down Expand Up @@ -313,9 +324,7 @@ def do_generate_solution(build_dir, cmake_script_dir, args):
cpu = args.cpu
config = args.config

is_arm64_cpu = False
if platform.machine() == 'arm64' or platform.machine() == 'aarch64':
is_arm64_cpu = True
is_arm64_cpu = is_arm64_host()

if compiler:
set_compiler_env(compiler, args)
Expand Down