Skip to content
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
326aea2
Implement the first few SIMD opcodes for fast interpreter (v128.const…
loganek Sep 27, 2024
860379b
implement POP_V128()
loganek Oct 1, 2024
f7f1491
Merge pull request #3832 from loganek/loganek/simd
loganek Oct 7, 2024
5b2ab61
Add all SIMD operations into wasm_interp_fast switch
Sep 27, 2024
c1bfe2a
Add V128 comparison operations
Oct 1, 2024
2e61591
Merge pull request #3833 from jammar1/jamamr1/add_stubs_and_one_imp
loganek Oct 15, 2024
aceaed6
Merge pull request #3873 from bytecodealliance/main
wenyongh Oct 23, 2024
c930c4d
Add first NEON SIMD opcode implementations to fast interpreter (#3859)
jammar1 Nov 5, 2024
fbbcd08
Emit imm for lane extract and replace (#3906)
Zzzabiyaka Nov 13, 2024
c3601cc
Fix replacement value not being correct (#3919)
Zzzabiyaka Nov 22, 2024
7b704e4
Merge pull request #3925 from bytecodealliance/main
wenyongh Nov 23, 2024
cfcb946
Replace/extract opcodes for fast interp
Zzzabiyaka Nov 25, 2024
09b7fae
Merge pull request #3930 from Zzzabiyaka/makslit/load_opcodes
loganek Nov 25, 2024
138faba
Implement load lanes opcodes for wasm (#3942)
Zzzabiyaka Dec 3, 2024
4cb9b1b
Add zero load opcodes
Zzzabiyaka Dec 23, 2024
dea195f
Merge pull request #3943 from Zzzabiyaka/makslit/load_opcodes
loganek Dec 23, 2024
441440f
Implement final SIMD opcodes: store lane (#4001)
jammar1 Jan 2, 2025
07fd987
Fix boolean tests
Zzzabiyaka Jan 6, 2025
8ce74b7
Fix load/store (#4054)
Zzzabiyaka Feb 1, 2025
50faad0
Correctly use unsigned functions (#4055)
Zzzabiyaka Feb 1, 2025
474acd7
implement local and function calls for v128 in the fast interpreter
Zzzabiyaka Jan 3, 2025
b2804c0
Fix splat opcodes, add V128 handling in preserve_referenced_local and…
Jan 21, 2025
28d74d2
implement globals
Zzzabiyaka Jan 21, 2025
80e6c98
Fix incorrect memory overflow values + SIMD ifdefs
Jan 24, 2025
bd97970
Fix load/load_splat macros
Jan 22, 2025
253d741
formatting commit
Zzzabiyaka Jan 27, 2025
72535e4
correct endif wasm loader
Zzzabiyaka Jan 27, 2025
d01b702
Update core/iwasm/interpreter/wasm_opcode.h
Zzzabiyaka Jan 28, 2025
595a2b3
Update core/iwasm/interpreter/wasm_opcode.h
Zzzabiyaka Jan 28, 2025
1b267b0
Update core/iwasm/interpreter/wasm_opcode.h
Zzzabiyaka Jan 28, 2025
f7c4e9f
Update core/iwasm/interpreter/wasm_opcode.h
Zzzabiyaka Jan 28, 2025
3e9a5b0
Fixes
Zzzabiyaka Jan 28, 2025
93feee8
Fix load/store
Zzzabiyaka Jan 24, 2025
59cfa1a
Fix spec tests when WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS is 0
Feb 17, 2025
2d2b173
Merge remote-tracking branch 'original/main' into mrshnja/merge-main-…
Feb 21, 2025
dea2e16
Resolve merge conflicts arising from main -> dev/simd_for_interp and …
Feb 21, 2025
7ba7509
Merge pull request #4098 from jammar1/mrshnja/merge-main-to-dev-simd-2
loganek Feb 25, 2025
05a25df
Enable SIMDe tests on CI
Feb 19, 2025
a16c0ae
Merge pull request #4125 from jammar1/mrshnja/wamr-ci-simd-interp
loganek Mar 7, 2025
418195a
Apply clang-format to dev/simd_for_interp
Mar 17, 2025
a227336
Merge pull request #4143 from jammar1/jammar1/clang-format
loganek Mar 17, 2025
e9d25f9
Document WAMR_BUILD_LIB_SIMDE
Mar 18, 2025
eb1771f
Merge pull request #4144 from jammar1/mrshnja/add-documentation-simd
loganek Mar 18, 2025
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
9 changes: 3 additions & 6 deletions .github/workflows/compilation_on_android_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ jobs:
"-DWAMR_BUILD_PERF_PROFILING=1",
"-DWAMR_BUILD_REF_TYPES=1",
"-DWAMR_BUILD_SIMD=1",
"-DWAMR_BUILD_LIB_SIMDE=1",
"-DWAMR_BUILD_TAIL_CALL=1",
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
"-DWAMR_BUILD_MEMORY64=1",
Expand All @@ -178,11 +179,9 @@ jobs:
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
# SIMD only on JIT/AOT mode
# SIMD only on JIT/AOT/fast interpreter mode
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_SIMD=1"
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_SIMD=1"
# DEBUG_INTERP only on CLASSIC INTERP mode
- make_options_run_mode: $AOT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
Expand Down Expand Up @@ -649,11 +648,9 @@ jobs:
test_option: $WAMR_COMPILER_TEST_OPTIONS
exclude:
# incompatible modes and features
# classic-interp and fast-interp don't support simd
# classic-interp doesn't support simd
- running_mode: "classic-interp"
test_option: $SIMD_TEST_OPTIONS
- running_mode: "fast-interp"
test_option: $SIMD_TEST_OPTIONS
# llvm jit doesn't support multi module
- running_mode: "jit"
test_option: $MULTI_MODULES_TEST_OPTIONS
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/compilation_on_sgx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ env:
# ref types enabled in wamrc by default, so we need to enable it for iwasm in AOT mode
AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0 -DWAMR_BUILD_REF_TYPES=1"
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0 -DWAMR_BUILD_SIMD=0"
FAST_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=1"
LLVM_LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
"-DWAMR_BUILD_PERF_PROFILING=1",
"-DWAMR_BUILD_REF_TYPES=1",
# doesn't support
# "-DWAMR_BUILD_SIMD=1",
"-DWAMR_BUILD_SIMD=0",
"-DWAMR_BUILD_TAIL_CALL=1",
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
"-DWAMR_BUILD_SGX_IPFS=1",
Expand Down
15 changes: 12 additions & 3 deletions build-scripts/config_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ endif ()
if (WAMR_BUILD_LIB_RATS EQUAL 1)
message (" Lib rats enabled")
endif()
if ((WAMR_BUILD_LIB_SIMDE EQUAL 1))
message (" Lib simde enabled")
endif()
################## WAMR features ##################
if (WAMR_BUILD_MULTI_MODULE EQUAL 1)
add_definitions (-DWASM_ENABLE_MULTI_MODULE=1)
Expand Down Expand Up @@ -363,11 +366,17 @@ else ()
message (" Wakeup of blocking operations enabled")
endif ()
if (WAMR_BUILD_SIMD EQUAL 1)
if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*")
add_definitions (-DWASM_ENABLE_SIMD=1)
else ()
if (WAMR_BUILD_FAST_INTERP EQUAL 1 AND WAMR_BUILD_SIMDE EQUAL 0)
set(SIMD_ENABLED 0)
message(" SIMD disabled for fast-interp as simde is not being built")
elseif (WAMR_BUILD_TARGET MATCHES "RISCV64.*")
set(SIMD_ENABLED 0)
message (" SIMD disabled due to not supported on target RISCV64")
else()
set(SIMD_ENABLED 1)
message (" SIMD enabled")
endif ()
add_definitions(-DWASM_ENABLE_SIMD=${SIMD_ENABLED})
endif ()
if (WAMR_BUILD_AOT_STACK_FRAME EQUAL 1)
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
Expand Down
10 changes: 10 additions & 0 deletions build-scripts/runtime_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ if (WAMR_BUILD_LIB_RATS EQUAL 1)
include (${IWASM_DIR}/libraries/lib-rats/lib_rats.cmake)
endif ()

if (WAMR_BUILD_SIMD EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1)
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
message(STATUS "SIMDe doesnt support platform " ${WAMR_BUILD_PLATFORM})
set(WAMR_BUILD_SIMDE 0)
else()
include (${IWASM_DIR}/libraries/simde/simde.cmake)
set (WAMR_BUILD_SIMDE 1)
endif()
endif ()

if (WAMR_BUILD_WASM_CACHE EQUAL 1)
include (${WAMR_ROOT_DIR}/build-scripts/involve_boringssl.cmake)
endif ()
Expand Down
6 changes: 6 additions & 0 deletions core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@
#define WASM_ENABLE_SIMD 0
#endif

/* Disable SIMDe (used in the fast interpreter for SIMD opcodes)
unless used elsewhere */
#ifndef WASM_ENABLE_SIMDE
#define WASM_ENABLE_SIMDE 0
#endif

/* GC performance profiling */
#ifndef WASM_ENABLE_GC_PERF_PROFILING
#define WASM_ENABLE_GC_PERF_PROFILING 0
Expand Down
3 changes: 2 additions & 1 deletion core/iwasm/common/wasm_loader_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ is_valid_value_type(uint8 type)
bool
is_valid_value_type_for_interpreter(uint8 value_type)
{
#if (WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0)
#if (WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0) \
&& (WASM_ENABLE_FAST_INTERP == 0)
/*
* Note: regardless of WASM_ENABLE_SIMD, our interpreters don't have
* SIMD implemented. It's safer to reject v128, especially for the
Expand Down
119 changes: 119 additions & 0 deletions core/iwasm/common/wasm_runtime_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ extern "C" {
do { \
*(int64 *)(addr) = (int64)(value); \
} while (0)
#define PUT_V128_TO_ADDR(addr, value) \
do { \
*(V128 *)(addr) = (value); \
} while (0)
#define PUT_F64_TO_ADDR(addr, value) \
do { \
*(float64 *)(addr) = (float64)(value); \
Expand All @@ -49,6 +53,7 @@ extern "C" {
#define GET_I64_FROM_ADDR(addr) (*(int64 *)(addr))
#define GET_F64_FROM_ADDR(addr) (*(float64 *)(addr))
#define GET_REF_FROM_ADDR(addr) (*(void **)(addr))
#define GET_V128_FROM_ADDR(addr) (*(V128 *)(addr))

/* For STORE opcodes */
#define STORE_I64 PUT_I64_TO_ADDR
Expand All @@ -68,13 +73,20 @@ STORE_U8(void *addr, uint8_t value)
*(uint8 *)addr = value;
}

static inline void
STORE_V128(void *addr, V128 value)
{
*(V128 *)addr = value;
}

/* For LOAD opcodes */
#define LOAD_I64(addr) (*(int64 *)(addr))
#define LOAD_F64(addr) (*(float64 *)(addr))
#define LOAD_I32(addr) (*(int32 *)(addr))
#define LOAD_U32(addr) (*(uint32 *)(addr))
#define LOAD_I16(addr) (*(int16 *)(addr))
#define LOAD_U16(addr) (*(uint16 *)(addr))
#define LOAD_V128(addr) (*(V128 *)(addr))

#define STORE_PTR(addr, ptr) \
do { \
Expand All @@ -83,6 +95,15 @@ STORE_U8(void *addr, uint8_t value)

#else /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */

#define PUT_V128_TO_ADDR(addr, value) \
do { \
uint32 *addr_u32 = (uint32 *)(addr); \
addr_u32[0] = (value).i32x4[0]; \
addr_u32[1] = (value).i32x4[1]; \
addr_u32[2] = (value).i32x4[2]; \
addr_u32[3] = (value).i32x4[3]; \
} while (0)

#define PUT_I64_TO_ADDR(addr, value) \
do { \
uint32 *addr_u32 = (uint32 *)(addr); \
Expand Down Expand Up @@ -124,6 +145,17 @@ STORE_U8(void *addr, uint8_t value)
} while (0)
#endif

static inline V128
GET_V128_FROM_ADDR(uint32 *addr)
{
V128 ret;
ret.i32x4[0] = addr[0];
ret.i32x4[1] = addr[1];
ret.i32x4[2] = addr[2];
ret.i32x4[3] = addr[3];
return ret;
}

static inline int64
GET_I64_FROM_ADDR(uint32 *addr)
{
Expand Down Expand Up @@ -239,7 +271,94 @@ STORE_U16(void *addr, uint16_t value)
((uint8_t *)(addr))[0] = u.u8[0];
((uint8_t *)(addr))[1] = u.u8[1];
}

static inline void
STORE_V128(void *addr, V128 value)
{
uintptr_t addr_ = (uintptr_t)(addr);
union {
V128 val;
uint64 u64[2];
uint32 u32[4];
uint16 u16[8];
uint8 u8[16];
} u;

if ((addr_ & (uintptr_t)15) == 0) {
*(V128 *)addr = value;
}
else if ((addr_ & (uintptr_t)7) == 0) {
u.val = value;
((uint64 *)(addr))[0] = u.u64[0];
((uint64 *)(addr))[1] = u.u64[1];
}
else if ((addr_ & (uintptr_t)3) == 0) {
u.val = value;
((uint32 *)addr)[0] = u.u32[0];
((uint32 *)addr)[1] = u.u32[1];
((uint32 *)addr)[2] = u.u32[2];
((uint32 *)addr)[3] = u.u32[3];
}
else if ((addr_ & (uintptr_t)1) == 0) {
u.val = value;
((uint16 *)addr)[0] = u.u16[0];
((uint16 *)addr)[1] = u.u16[1];
((uint16 *)addr)[2] = u.u16[2];
((uint16 *)addr)[3] = u.u16[3];
((uint16 *)addr)[4] = u.u16[4];
((uint16 *)addr)[5] = u.u16[5];
((uint16 *)addr)[6] = u.u16[6];
((uint16 *)addr)[7] = u.u16[7];
}
else {
u.val = value;
for (int i = 0; i < 16; i++)
((uint8 *)addr)[i] = u.u8[i];
}
}

/* For LOAD opcodes */
static inline V128
LOAD_V128(void *addr)
{
uintptr_t addr1 = (uintptr_t)addr;
union {
V128 val;
uint64 u64[2];
uint32 u32[4];
uint16 u16[8];
uint8 u8[16];
} u;
if ((addr1 & (uintptr_t)15) == 0)
return *(V128 *)addr;

if ((addr1 & (uintptr_t)7) == 0) {
u.u64[0] = ((uint64 *)addr)[0];
u.u64[1] = ((uint64 *)addr)[1];
}
else if ((addr1 & (uintptr_t)3) == 0) {
u.u32[0] = ((uint32 *)addr)[0];
u.u32[1] = ((uint32 *)addr)[1];
u.u32[2] = ((uint32 *)addr)[2];
u.u32[3] = ((uint32 *)addr)[3];
}
else if ((addr1 & (uintptr_t)1) == 0) {
u.u16[0] = ((uint16 *)addr)[0];
u.u16[1] = ((uint16 *)addr)[1];
u.u16[2] = ((uint16 *)addr)[2];
u.u16[3] = ((uint16 *)addr)[3];
u.u16[4] = ((uint16 *)addr)[4];
u.u16[5] = ((uint16 *)addr)[5];
u.u16[6] = ((uint16 *)addr)[6];
u.u16[7] = ((uint16 *)addr)[7];
}
else {
for (int i = 0; i < 16; i++)
u.u8[i] = ((uint8 *)addr)[i];
}
return u.val;
}

static inline int64
LOAD_I64(void *addr)
{
Expand Down
Loading
Loading