vcomp/tests: Add tests for 16-bit atomic instructions.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
284058073d
commit
b86ed6fe15
|
@ -35,34 +35,45 @@ static VOID (WINAPI *pReleaseActCtx)(HANDLE);
|
||||||
typedef CRITICAL_SECTION *omp_lock_t;
|
typedef CRITICAL_SECTION *omp_lock_t;
|
||||||
typedef CRITICAL_SECTION *omp_nest_lock_t;
|
typedef CRITICAL_SECTION *omp_nest_lock_t;
|
||||||
|
|
||||||
|
static void (CDECL *p_vcomp_atomic_add_i2)(short *dest, short val);
|
||||||
static void (CDECL *p_vcomp_atomic_add_i4)(int *dest, int val);
|
static void (CDECL *p_vcomp_atomic_add_i4)(int *dest, int val);
|
||||||
static void (CDECL *p_vcomp_atomic_add_i8)(LONG64 *dest, LONG64 val);
|
static void (CDECL *p_vcomp_atomic_add_i8)(LONG64 *dest, LONG64 val);
|
||||||
static void (CDECL *p_vcomp_atomic_add_r4)(float *dest, float val);
|
static void (CDECL *p_vcomp_atomic_add_r4)(float *dest, float val);
|
||||||
static void (CDECL *p_vcomp_atomic_add_r8)(double *dest, double val);
|
static void (CDECL *p_vcomp_atomic_add_r8)(double *dest, double val);
|
||||||
|
static void (CDECL *p_vcomp_atomic_and_i2)(short *dest, short val);
|
||||||
static void (CDECL *p_vcomp_atomic_and_i4)(int *dest, int val);
|
static void (CDECL *p_vcomp_atomic_and_i4)(int *dest, int val);
|
||||||
static void (CDECL *p_vcomp_atomic_and_i8)(LONG64 *dest, LONG64 val);
|
static void (CDECL *p_vcomp_atomic_and_i8)(LONG64 *dest, LONG64 val);
|
||||||
|
static void (CDECL *p_vcomp_atomic_div_i2)(short *dest, short val);
|
||||||
static void (CDECL *p_vcomp_atomic_div_i4)(int *dest, int val);
|
static void (CDECL *p_vcomp_atomic_div_i4)(int *dest, int val);
|
||||||
static void (CDECL *p_vcomp_atomic_div_i8)(LONG64 *dest, LONG64 val);
|
static void (CDECL *p_vcomp_atomic_div_i8)(LONG64 *dest, LONG64 val);
|
||||||
static void (CDECL *p_vcomp_atomic_div_r4)(float *dest, float val);
|
static void (CDECL *p_vcomp_atomic_div_r4)(float *dest, float val);
|
||||||
static void (CDECL *p_vcomp_atomic_div_r8)(double *dest, double val);
|
static void (CDECL *p_vcomp_atomic_div_r8)(double *dest, double val);
|
||||||
|
static void (CDECL *p_vcomp_atomic_div_ui2)(unsigned short *dest, unsigned short val);
|
||||||
static void (CDECL *p_vcomp_atomic_div_ui4)(unsigned int *dest, unsigned int val);
|
static void (CDECL *p_vcomp_atomic_div_ui4)(unsigned int *dest, unsigned int val);
|
||||||
static void (CDECL *p_vcomp_atomic_div_ui8)(ULONG64 *dest, ULONG64 val);
|
static void (CDECL *p_vcomp_atomic_div_ui8)(ULONG64 *dest, ULONG64 val);
|
||||||
|
static void (CDECL *p_vcomp_atomic_mul_i2)(short *dest, short val);
|
||||||
static void (CDECL *p_vcomp_atomic_mul_i4)(int *dest, int val);
|
static void (CDECL *p_vcomp_atomic_mul_i4)(int *dest, int val);
|
||||||
static void (CDECL *p_vcomp_atomic_mul_i8)(LONG64 *dest, LONG64 val);
|
static void (CDECL *p_vcomp_atomic_mul_i8)(LONG64 *dest, LONG64 val);
|
||||||
static void (CDECL *p_vcomp_atomic_mul_r4)(float *dest, float val);
|
static void (CDECL *p_vcomp_atomic_mul_r4)(float *dest, float val);
|
||||||
static void (CDECL *p_vcomp_atomic_mul_r8)(double *dest, double val);
|
static void (CDECL *p_vcomp_atomic_mul_r8)(double *dest, double val);
|
||||||
|
static void (CDECL *p_vcomp_atomic_or_i2)(short *dest, short val);
|
||||||
static void (CDECL *p_vcomp_atomic_or_i4)(int *dest, int val);
|
static void (CDECL *p_vcomp_atomic_or_i4)(int *dest, int val);
|
||||||
static void (CDECL *p_vcomp_atomic_or_i8)(LONG64 *dest, LONG64 val);
|
static void (CDECL *p_vcomp_atomic_or_i8)(LONG64 *dest, LONG64 val);
|
||||||
|
static void (CDECL *p_vcomp_atomic_shl_i2)(short *dest, unsigned int val);
|
||||||
static void (CDECL *p_vcomp_atomic_shl_i4)(int *dest, int val);
|
static void (CDECL *p_vcomp_atomic_shl_i4)(int *dest, int val);
|
||||||
static void (CDECL *p_vcomp_atomic_shl_i8)(LONG64 *dest, unsigned int val);
|
static void (CDECL *p_vcomp_atomic_shl_i8)(LONG64 *dest, unsigned int val);
|
||||||
|
static void (CDECL *p_vcomp_atomic_shr_i2)(short *dest, unsigned int val);
|
||||||
static void (CDECL *p_vcomp_atomic_shr_i4)(int *dest, int val);
|
static void (CDECL *p_vcomp_atomic_shr_i4)(int *dest, int val);
|
||||||
static void (CDECL *p_vcomp_atomic_shr_i8)(LONG64 *dest, unsigned int val);
|
static void (CDECL *p_vcomp_atomic_shr_i8)(LONG64 *dest, unsigned int val);
|
||||||
|
static void (CDECL *p_vcomp_atomic_shr_ui2)(unsigned short *dest, unsigned int val);
|
||||||
static void (CDECL *p_vcomp_atomic_shr_ui4)(unsigned int *dest, unsigned int val);
|
static void (CDECL *p_vcomp_atomic_shr_ui4)(unsigned int *dest, unsigned int val);
|
||||||
static void (CDECL *p_vcomp_atomic_shr_ui8)(ULONG64 *dest, unsigned int val);
|
static void (CDECL *p_vcomp_atomic_shr_ui8)(ULONG64 *dest, unsigned int val);
|
||||||
|
static void (CDECL *p_vcomp_atomic_sub_i2)(short *dest, short val);
|
||||||
static void (CDECL *p_vcomp_atomic_sub_i4)(int *dest, int val);
|
static void (CDECL *p_vcomp_atomic_sub_i4)(int *dest, int val);
|
||||||
static void (CDECL *p_vcomp_atomic_sub_i8)(LONG64 *dest, LONG64 val);
|
static void (CDECL *p_vcomp_atomic_sub_i8)(LONG64 *dest, LONG64 val);
|
||||||
static void (CDECL *p_vcomp_atomic_sub_r4)(float *dest, float val);
|
static void (CDECL *p_vcomp_atomic_sub_r4)(float *dest, float val);
|
||||||
static void (CDECL *p_vcomp_atomic_sub_r8)(double *dest, double val);
|
static void (CDECL *p_vcomp_atomic_sub_r8)(double *dest, double val);
|
||||||
|
static void (CDECL *p_vcomp_atomic_xor_i2)(short *dest, short val);
|
||||||
static void (CDECL *p_vcomp_atomic_xor_i4)(int *dest, int val);
|
static void (CDECL *p_vcomp_atomic_xor_i4)(int *dest, int val);
|
||||||
static void (CDECL *p_vcomp_atomic_xor_i8)(LONG64 *dest, LONG64 val);
|
static void (CDECL *p_vcomp_atomic_xor_i8)(LONG64 *dest, LONG64 val);
|
||||||
static void (CDECL *p_vcomp_barrier)(void);
|
static void (CDECL *p_vcomp_barrier)(void);
|
||||||
|
@ -249,34 +260,45 @@ static BOOL init_vcomp(void)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VCOMP_GET_PROC(_vcomp_atomic_add_i2);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_add_i4);
|
VCOMP_GET_PROC(_vcomp_atomic_add_i4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_add_i8);
|
VCOMP_GET_PROC(_vcomp_atomic_add_i8);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_add_r4);
|
VCOMP_GET_PROC(_vcomp_atomic_add_r4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_add_r8);
|
VCOMP_GET_PROC(_vcomp_atomic_add_r8);
|
||||||
|
VCOMP_GET_PROC(_vcomp_atomic_and_i2);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_and_i4);
|
VCOMP_GET_PROC(_vcomp_atomic_and_i4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_and_i8);
|
VCOMP_GET_PROC(_vcomp_atomic_and_i8);
|
||||||
|
VCOMP_GET_PROC(_vcomp_atomic_div_i2);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_div_i4);
|
VCOMP_GET_PROC(_vcomp_atomic_div_i4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_div_i8);
|
VCOMP_GET_PROC(_vcomp_atomic_div_i8);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_div_r4);
|
VCOMP_GET_PROC(_vcomp_atomic_div_r4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_div_r8);
|
VCOMP_GET_PROC(_vcomp_atomic_div_r8);
|
||||||
|
VCOMP_GET_PROC(_vcomp_atomic_div_ui2);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_div_ui4);
|
VCOMP_GET_PROC(_vcomp_atomic_div_ui4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_div_ui8);
|
VCOMP_GET_PROC(_vcomp_atomic_div_ui8);
|
||||||
|
VCOMP_GET_PROC(_vcomp_atomic_mul_i2);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_mul_i4);
|
VCOMP_GET_PROC(_vcomp_atomic_mul_i4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_mul_i8);
|
VCOMP_GET_PROC(_vcomp_atomic_mul_i8);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_mul_r4);
|
VCOMP_GET_PROC(_vcomp_atomic_mul_r4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_mul_r8);
|
VCOMP_GET_PROC(_vcomp_atomic_mul_r8);
|
||||||
|
VCOMP_GET_PROC(_vcomp_atomic_or_i2);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_or_i4);
|
VCOMP_GET_PROC(_vcomp_atomic_or_i4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_or_i8);
|
VCOMP_GET_PROC(_vcomp_atomic_or_i8);
|
||||||
|
VCOMP_GET_PROC(_vcomp_atomic_shl_i2);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_shl_i4);
|
VCOMP_GET_PROC(_vcomp_atomic_shl_i4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_shl_i8);
|
VCOMP_GET_PROC(_vcomp_atomic_shl_i8);
|
||||||
|
VCOMP_GET_PROC(_vcomp_atomic_shr_i2);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_shr_i4);
|
VCOMP_GET_PROC(_vcomp_atomic_shr_i4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_shr_i8);
|
VCOMP_GET_PROC(_vcomp_atomic_shr_i8);
|
||||||
|
VCOMP_GET_PROC(_vcomp_atomic_shr_ui2);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_shr_ui4);
|
VCOMP_GET_PROC(_vcomp_atomic_shr_ui4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_shr_ui8);
|
VCOMP_GET_PROC(_vcomp_atomic_shr_ui8);
|
||||||
|
VCOMP_GET_PROC(_vcomp_atomic_sub_i2);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_sub_i4);
|
VCOMP_GET_PROC(_vcomp_atomic_sub_i4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_sub_i8);
|
VCOMP_GET_PROC(_vcomp_atomic_sub_i8);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_sub_r4);
|
VCOMP_GET_PROC(_vcomp_atomic_sub_r4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_sub_r8);
|
VCOMP_GET_PROC(_vcomp_atomic_sub_r8);
|
||||||
|
VCOMP_GET_PROC(_vcomp_atomic_xor_i2);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_xor_i4);
|
VCOMP_GET_PROC(_vcomp_atomic_xor_i4);
|
||||||
VCOMP_GET_PROC(_vcomp_atomic_xor_i8);
|
VCOMP_GET_PROC(_vcomp_atomic_xor_i8);
|
||||||
VCOMP_GET_PROC(_vcomp_barrier);
|
VCOMP_GET_PROC(_vcomp_barrier);
|
||||||
|
@ -1422,6 +1444,99 @@ static void test_omp_init_nest_lock(void)
|
||||||
pomp_destroy_nest_lock(&lock);
|
pomp_destroy_nest_lock(&lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_atomic_integer16(void)
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
void (CDECL *func)(short *, short);
|
||||||
|
short v1, v2, expected;
|
||||||
|
}
|
||||||
|
tests1[] =
|
||||||
|
{
|
||||||
|
{ p_vcomp_atomic_add_i2, 0x1122, 0x7766, -0x7778 },
|
||||||
|
{ p_vcomp_atomic_and_i2, 0x1122, 0x7766, 0x1122 },
|
||||||
|
{ p_vcomp_atomic_div_i2, 0x7766, 0x1122, 6 },
|
||||||
|
{ p_vcomp_atomic_div_i2, 0x7766, -0x1122, -6 },
|
||||||
|
{ p_vcomp_atomic_mul_i2, 0x1122, 0x7766, -0x5e74 },
|
||||||
|
{ p_vcomp_atomic_mul_i2, 0x1122, -0x7766, 0x5e74 },
|
||||||
|
{ p_vcomp_atomic_or_i2, 0x1122, 0x7766, 0x7766 },
|
||||||
|
{ p_vcomp_atomic_sub_i2, 0x1122, 0x7766, -0x6644 },
|
||||||
|
{ p_vcomp_atomic_xor_i2, 0x1122, 0x7766, 0x6644 },
|
||||||
|
};
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
void (CDECL *func)(short *, unsigned int);
|
||||||
|
short v1;
|
||||||
|
unsigned int v2;
|
||||||
|
short expected;
|
||||||
|
}
|
||||||
|
tests2[] =
|
||||||
|
{
|
||||||
|
{ p_vcomp_atomic_shl_i2, 0x1122, 3, -0x76f0 },
|
||||||
|
{ p_vcomp_atomic_shl_i2, -0x1122, 3, 0x76f0 },
|
||||||
|
{ p_vcomp_atomic_shr_i2, 0x1122, 3, 0x224 },
|
||||||
|
{ p_vcomp_atomic_shr_i2, -0x1122, 3, -0x225 },
|
||||||
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
|
{ p_vcomp_atomic_shl_i2, 0x1122, 19, 0 },
|
||||||
|
{ p_vcomp_atomic_shl_i2, 0x1122, 35, -0x76f0 },
|
||||||
|
{ p_vcomp_atomic_shr_i2, 0x1122, 19, 0 },
|
||||||
|
{ p_vcomp_atomic_shr_i2, 0x1122, 35, 0x224 },
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
void (CDECL *func)(unsigned short *, unsigned short);
|
||||||
|
unsigned short v1, v2, expected;
|
||||||
|
}
|
||||||
|
tests3[] =
|
||||||
|
{
|
||||||
|
{ p_vcomp_atomic_div_ui2, 0x7766, 0x1122, 6 },
|
||||||
|
{ p_vcomp_atomic_div_ui2, 0x7766, 0xeede, 0 },
|
||||||
|
};
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
void (CDECL *func)(unsigned short *, unsigned int);
|
||||||
|
unsigned short v1;
|
||||||
|
unsigned int v2;
|
||||||
|
unsigned short expected;
|
||||||
|
}
|
||||||
|
tests4[] =
|
||||||
|
{
|
||||||
|
{ p_vcomp_atomic_shr_ui2, 0x1122, 3, 0x224 },
|
||||||
|
{ p_vcomp_atomic_shr_ui2, 0xeede, 3, 0x1ddb },
|
||||||
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
|
{ p_vcomp_atomic_shr_ui2, 0x1122, 19, 0 },
|
||||||
|
{ p_vcomp_atomic_shr_ui2, 0x1122, 35, 0x224 },
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(tests1)/sizeof(tests1[0]); i++)
|
||||||
|
{
|
||||||
|
short val = tests1[i].v1;
|
||||||
|
tests1[i].func(&val, tests1[i].v2);
|
||||||
|
ok(val == tests1[i].expected, "test %d: expected val == %d, got %d\n", i, tests1[i].expected, val);
|
||||||
|
}
|
||||||
|
for (i = 0; i < sizeof(tests2)/sizeof(tests2[0]); i++)
|
||||||
|
{
|
||||||
|
short val = tests2[i].v1;
|
||||||
|
tests2[i].func(&val, tests2[i].v2);
|
||||||
|
ok(val == tests2[i].expected, "test %d: expected val == %d, got %d\n", i, tests2[i].expected, val);
|
||||||
|
}
|
||||||
|
for (i = 0; i < sizeof(tests3)/sizeof(tests3[0]); i++)
|
||||||
|
{
|
||||||
|
unsigned short val = tests3[i].v1;
|
||||||
|
tests3[i].func(&val, tests3[i].v2);
|
||||||
|
ok(val == tests3[i].expected, "test %d: expected val == %u, got %u\n", i, tests3[i].expected, val);
|
||||||
|
}
|
||||||
|
for (i = 0; i < sizeof(tests4)/sizeof(tests4[0]); i++)
|
||||||
|
{
|
||||||
|
unsigned short val = tests4[i].v1;
|
||||||
|
tests4[i].func(&val, tests4[i].v2);
|
||||||
|
ok(val == tests4[i].expected, "test %d: expected val == %u, got %u\n", i, tests4[i].expected, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void test_atomic_integer32(void)
|
static void test_atomic_integer32(void)
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
|
@ -1656,6 +1771,7 @@ START_TEST(vcomp)
|
||||||
test_vcomp_flush();
|
test_vcomp_flush();
|
||||||
test_omp_init_lock();
|
test_omp_init_lock();
|
||||||
test_omp_init_nest_lock();
|
test_omp_init_nest_lock();
|
||||||
|
test_atomic_integer16();
|
||||||
test_atomic_integer32();
|
test_atomic_integer32();
|
||||||
test_atomic_integer64();
|
test_atomic_integer64();
|
||||||
test_atomic_float();
|
test_atomic_float();
|
||||||
|
|
Loading…
Reference in New Issue