| 9 | #include "test.h" |
| 10 | |
| 11 | FL_TEST_FILE(FL_FILEPATH) { |
| 12 | |
| 13 | using namespace fl; |
| 14 | |
| 15 | //============================================================================== |
| 16 | // Atomic Load/Store Tests |
| 17 | //============================================================================== |
| 18 | |
| 19 | FL_TEST_CASE("load_u8_16 loads 16 bytes correctly") { |
| 20 | uint8_t src[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; |
| 21 | uint8_t dst[16] = {0}; |
| 22 | |
| 23 | auto vec = simd::load_u8_16(src); |
| 24 | simd::store_u8_16(dst, vec); |
| 25 | |
| 26 | for (int i = 0; i < 16; ++i) { |
| 27 | FL_REQUIRE(dst[i] == src[i]); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | FL_TEST_CASE("load_u32_4 loads 4 uint32_t correctly") { |
| 32 | uint32_t src[4] = {0x12345678, 0xABCDEF00, 0xDEADBEEF, 0xCAFEBABE}; |
| 33 | uint32_t dst[4] = {0}; |
| 34 | |
| 35 | auto vec = simd::load_u32_4(src); |
| 36 | simd::store_u32_4(dst, vec); |
| 37 | |
| 38 | for (int i = 0; i < 4; ++i) { |
| 39 | FL_REQUIRE(dst[i] == src[i]); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | FL_TEST_CASE("store_u8_16 stores 16 bytes correctly") { |
| 44 | uint8_t buffer[32] = {0}; // Extra space to check bounds |
| 45 | uint8_t pattern[16] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160}; |
| 46 | |
| 47 | auto vec = simd::load_u8_16(pattern); |
| 48 | simd::store_u8_16(&buffer[8], vec); // Store in middle |
| 49 | |
| 50 | // Check pattern stored correctly |
| 51 | for (int i = 0; i < 16; ++i) { |
| 52 | FL_REQUIRE(buffer[8 + i] == pattern[i]); |
| 53 | } |
| 54 | |
| 55 | // Check boundaries not overwritten |
| 56 | for (int i = 0; i < 8; ++i) { |
| 57 | FL_REQUIRE(buffer[i] == 0); |
| 58 | FL_REQUIRE(buffer[24 + i] == 0); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | FL_TEST_CASE("store_u32_4 stores 4 uint32_t correctly") { |
| 63 | uint32_t buffer[8] = {0}; // Extra space to check bounds |
| 64 | uint32_t pattern[4] = {0x11111111, 0x22222222, 0x33333333, 0x44444444}; |
| 65 | |
| 66 | auto vec = simd::load_u32_4(pattern); |
| 67 | simd::store_u32_4(&buffer[2], vec); // Store in middle |
| 68 | |