Closed VergilWang15 closed 10 months ago
And here is my test code
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "xmath/xmath.h"
void test_memcpy(size_t num_elements) {
int32_t WORD_ALIGNED *src = (int32_t *)malloc(num_elements * sizeof(int32_t));
int32_t WORD_ALIGNED *dst = (int32_t *)malloc(num_elements * sizeof(int32_t));
int32_t WORD_ALIGNED *expected = (int32_t *)malloc(num_elements * sizeof(int32_t));
for (size_t i = 0; i < num_elements; ++i) {
src[i] = (int32_t)(0x12345678 + i);
}
xs3_memcpy(dst, src, num_elements * sizeof(int32_t));
memcpy(expected, src, num_elements * sizeof(int32_t));
for (size_t i = 0; i < num_elements; ++i) {
printf("expected[%zu]: 0x%08X, actually[%zu]: 0x%08X\n", i, expected[i], i, dst[i]);
}
free(src);
free(dst);
free(expected);
}
@VergilWang15, thank your for this report. We will investigate it and let you know what we find.
Hi @VergilWang15, I can suggest a drop-in solution while we investigate this issue.
There's a similar API which only works for the int32_t
arrays, called vect_s32_copy
. It does have a constraint for the number of elements of your array to be a multiple of 8, if that constraint is honoured the API will work much faster than the memcpy
for the long arrays.
Hi @VergilWang15,
The bug in xs3_memcpy
has been fixed and merged to develop
, it now behaves just as a memcpy
(but faster).
Thank you for reporting ✨
Hello,
I've encountered an issue with the
xs3_memcpy
function where its behavior is inconsistent with the standard C library'smemcpy
. I've written a simple function to compare the differences between the two.When testing with an
int32_t
array of length 4,xs3_memcpy
causes a crash with the following output:However, when the array length is 8,
xs3_memcpy
does not crash but produces completely incorrect values:Interestingly, when the array size is increased to 10, the last two elements are correct, but the rest are still wrong:
Is this issue due to incorrect usage on my part, or is there another underlying cause?
Thank you for your assistance.