[PATCH 1/3] vcomp: Add tests for _vcomp_for_dynamic_init_i8()

David Koller dk at cs.stanford.edu
Wed Feb 16 18:01:10 CST 2022


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52012
Signed-off-by: David Koller <dk at cs.stanford.edu>
---
 dlls/vcomp/tests/vcomp.c | 247 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 247 insertions(+)

diff --git a/dlls/vcomp/tests/vcomp.c b/dlls/vcomp/tests/vcomp.c
index a229e0198f7..19d56820450 100644
--- a/dlls/vcomp/tests/vcomp.c
+++ b/dlls/vcomp/tests/vcomp.c
@@ -87,7 +87,10 @@ static void  (CDECL   *p_vcomp_enter_critsect)(CRITICAL_SECTION **critsect);
 static void  (CDECL   *p_vcomp_flush)(void);
 static void  (CDECL   *p_vcomp_for_dynamic_init)(unsigned int flags, unsigned int first, unsigned int last,
                                                  int step, unsigned int chunksize);
+static void  (CDECL   *p_vcomp_for_dynamic_init_i8)(unsigned int flags, ULONG64 first, ULONG64 last,
+                                                    LONG64 step, ULONG64 chunksize);
 static int   (CDECL   *p_vcomp_for_dynamic_next)(unsigned int *begin, unsigned int *end);
+static int   (CDECL   *p_vcomp_for_dynamic_next_i8)(ULONG64 *begin, ULONG64 *end);
 static void  (CDECL   *p_vcomp_for_static_end)(void);
 static void  (CDECL   *p_vcomp_for_static_init)(int first, int last, int step, int chunksize, unsigned int *loops,
                                                 int *begin, int *end, int *next, int *lastchunk);
@@ -329,7 +332,9 @@ static BOOL init_vcomp(void)
     VCOMP_GET_PROC(_vcomp_enter_critsect);
     VCOMP_GET_PROC(_vcomp_flush);
     VCOMP_GET_PROC(_vcomp_for_dynamic_init);
+    VCOMP_GET_PROC(_vcomp_for_dynamic_init_i8);
     VCOMP_GET_PROC(_vcomp_for_dynamic_next);
+    VCOMP_GET_PROC(_vcomp_for_dynamic_next_i8);
     VCOMP_GET_PROC(_vcomp_for_static_end);
     VCOMP_GET_PROC(_vcomp_for_static_init);
     VCOMP_GET_PROC(_vcomp_for_static_init_i8);
@@ -1546,6 +1551,60 @@ static void CDECL for_dynamic_static_cb(void)
     ok(ret == FALSE, "expected ret == FALSE, got %d\n", ret);
 }
 
+static void CDECL for_dynamic_static_i8_cb(void)
+{
+    ULONG64 my_begin, my_end, begin, end;
+    int ret;
+
+    begin = end = 0xdeadbeef;
+    my_for_static_simple_init_i8(TRUE, 0, 1000, 7, TRUE, &my_begin, &my_end);
+    p_vcomp_for_dynamic_init_i8(VCOMP_DYNAMIC_FLAGS_STATIC | VCOMP_DYNAMIC_FLAGS_INCREMENT, 0, 1000, 7, 1);
+    ret = p_vcomp_for_dynamic_next_i8(&begin, &end);
+    ok(ret == TRUE, "expected ret == TRUE, got %d\n", ret);
+    ok(begin == my_begin, "expected begin == %s, got %s\n", wine_dbgstr_longlong(my_begin),
+       wine_dbgstr_longlong(begin));
+    ok(end == my_end, "expected end == %s, got %s\n", wine_dbgstr_longlong(my_end),
+       wine_dbgstr_longlong(end));
+    ret = p_vcomp_for_dynamic_next_i8(&begin, &end);
+    ok(ret == FALSE, "expected ret == FALSE, got %d\n", ret);
+
+    begin = end = 0xdeadbeef;
+    my_for_static_simple_init_i8(TRUE, 1000, 0, 7, FALSE, &my_begin, &my_end);
+    p_vcomp_for_dynamic_init_i8(VCOMP_DYNAMIC_FLAGS_STATIC, 1000, 0, 7, 1);
+    ret = p_vcomp_for_dynamic_next_i8(&begin, &end);
+    ok(ret == TRUE, "expected ret == TRUE, got %d\n", ret);
+    ok(begin == my_begin, "expected begin == %s, got %s\n", wine_dbgstr_longlong(my_begin),
+       wine_dbgstr_longlong(begin));
+    ok(end == my_end, "expected end == %s, got %s\n", wine_dbgstr_longlong(my_end),
+       wine_dbgstr_longlong(end));
+    ret = p_vcomp_for_dynamic_next_i8(&begin, &end);
+    ok(ret == FALSE, "expected ret == FALSE, got %d\n", ret);
+
+    begin = end = 0xdeadbeef;
+    my_for_static_simple_init_i8(TRUE, 0, 1000, 7, TRUE, &my_begin, &my_end);
+    p_vcomp_for_dynamic_init_i8(VCOMP_DYNAMIC_FLAGS_STATIC | VCOMP_DYNAMIC_FLAGS_INCREMENT, 0, 1000, 7, 5);
+    ret = p_vcomp_for_dynamic_next_i8(&begin, &end);
+    ok(ret == TRUE, "expected ret == TRUE, got %d\n", ret);
+    ok(begin == my_begin, "expected begin == %s, got %s\n", wine_dbgstr_longlong(my_begin),
+       wine_dbgstr_longlong(begin));
+    ok(end == my_end, "expected end == %s, got %s\n", wine_dbgstr_longlong(my_end),
+       wine_dbgstr_longlong(end));
+    ret = p_vcomp_for_dynamic_next_i8(&begin, &end);
+    ok(ret == FALSE, "expected ret == FALSE, got %d\n", ret);
+
+    begin = end = 0xdeadbeef;
+    my_for_static_simple_init_i8(TRUE, 1000, 0, 7, FALSE, &my_begin, &my_end);
+    p_vcomp_for_dynamic_init_i8(VCOMP_DYNAMIC_FLAGS_STATIC, 1000, 0, 7, 5);
+    ret = p_vcomp_for_dynamic_next_i8(&begin, &end);
+    ok(ret == TRUE, "expected ret == TRUE, got %d\n", ret);
+    ok(begin == my_begin, "expected begin == %s, got %s\n", wine_dbgstr_longlong(my_begin),
+       wine_dbgstr_longlong(begin));
+    ok(end == my_end, "expected end == %s, got %s\n", wine_dbgstr_longlong(my_end),
+       wine_dbgstr_longlong(end));
+    ret = p_vcomp_for_dynamic_next_i8(&begin, &end);
+    ok(ret == FALSE, "expected ret == FALSE, got %d\n", ret);
+}
+
 static void CDECL for_dynamic_chunked_cb(LONG *a, LONG *b, LONG *c, LONG *d)
 {
     unsigned int begin, end;
@@ -1583,6 +1642,47 @@ static void CDECL for_dynamic_chunked_cb(LONG *a, LONG *b, LONG *c, LONG *d)
     }
 }
 
+static void CDECL for_dynamic_chunked_i8_cb(LONG64 *a, LONG64 *b, LONG64 *c, LONG64 *d)
+{
+    ULONG64 begin, end;
+
+    p_vcomp_for_dynamic_init_i8(VCOMP_DYNAMIC_FLAGS_CHUNKED | VCOMP_DYNAMIC_FLAGS_INCREMENT, 0, 1000, 7, 1);
+    while (p_vcomp_for_dynamic_next_i8(&begin, &end))
+    {
+        if (begin == 994) ok(end == 1000, "expected end == 1000, got %s\n", wine_dbgstr_longlong(end));
+        else ok(begin == end, "expected begin == end, got %s and %s\n", wine_dbgstr_longlong(begin),
+                wine_dbgstr_longlong(end));
+        InterlockedExchangeAdd64(a, begin);
+    }
+
+    p_vcomp_for_dynamic_init_i8(VCOMP_DYNAMIC_FLAGS_CHUNKED, 1000, 0, 7, 1);
+    while (p_vcomp_for_dynamic_next_i8(&begin, &end))
+    {
+        if (begin == 6) ok(end == 0, "expected end == 0, got %s\n", wine_dbgstr_longlong(end));
+        else ok(begin == end, "expected begin == end, got %s and %s\n", wine_dbgstr_longlong(begin),
+                wine_dbgstr_longlong(end));
+        InterlockedExchangeAdd64(b, begin);
+    }
+
+    p_vcomp_for_dynamic_init_i8(VCOMP_DYNAMIC_FLAGS_CHUNKED | VCOMP_DYNAMIC_FLAGS_INCREMENT, 0, 1000, 7, 5);
+    while (p_vcomp_for_dynamic_next_i8(&begin, &end))
+    {
+        if (begin == 980) ok(end == 1000, "expected end == 1000, got %s\n", wine_dbgstr_longlong(end));
+        else ok(begin + 28 == end, "expected begin + 28 == end, got %s and %s\n",
+                wine_dbgstr_longlong(begin + 28), wine_dbgstr_longlong(end));
+        InterlockedExchangeAdd64(c, begin);
+    }
+
+    p_vcomp_for_dynamic_init_i8(VCOMP_DYNAMIC_FLAGS_CHUNKED, 1000, 0, 7, 5);
+    while (p_vcomp_for_dynamic_next_i8(&begin, &end))
+    {
+        if (begin == 20) ok(end == 0, "expected end == 0, got %s\n", wine_dbgstr_longlong(end));
+        else ok(begin - 28 == end, "expected begin - 28 == end, got %s and %s\n",
+                wine_dbgstr_longlong(begin - 28), wine_dbgstr_longlong(end));
+        InterlockedExchangeAdd64(d, begin);
+    }
+}
+
 static void CDECL for_dynamic_guided_cb(unsigned int flags, LONG *a, LONG *b, LONG *c, LONG *d)
 {
     int num_threads = pomp_get_num_threads();
@@ -1621,6 +1721,48 @@ static void CDECL for_dynamic_guided_cb(unsigned int flags, LONG *a, LONG *b, LO
     }
 }
 
+static void CDECL for_dynamic_guided_i8_cb(unsigned int flags, LONG64 *a, LONG64 *b, LONG64 *c, LONG64 *d)
+{
+    int num_threads = pomp_get_num_threads();
+    ULONG64 begin, end;
+
+    p_vcomp_for_dynamic_init_i8(flags | VCOMP_DYNAMIC_FLAGS_INCREMENT, 0, 1000, 7, 1);
+    while (p_vcomp_for_dynamic_next_i8(&begin, &end))
+    {
+        ok(num_threads != 1 || (begin == 0 && end == 1000),
+           "expected begin == 0 and end == 1000, got %s and %s\n", wine_dbgstr_longlong(begin),
+           wine_dbgstr_longlong(end));
+        InterlockedExchangeAdd64(a, begin);
+    }
+
+    p_vcomp_for_dynamic_init_i8(flags, 1000, 0, 7, 1);
+    while (p_vcomp_for_dynamic_next_i8(&begin, &end))
+    {
+        ok(num_threads != 1 || (begin == 1000 && end == 0),
+           "expected begin == 1000 and end == 0, got %s and %s\n", wine_dbgstr_longlong(begin),
+           wine_dbgstr_longlong(end));
+        InterlockedExchangeAdd64(b, begin);
+    }
+
+    p_vcomp_for_dynamic_init_i8(flags | VCOMP_DYNAMIC_FLAGS_INCREMENT, 0, 1000, 7, 5);
+    while (p_vcomp_for_dynamic_next_i8(&begin, &end))
+    {
+        ok(num_threads != 1 || (begin == 0 && end == 1000),
+           "expected begin == 0 and end == 1000, got %s and %s\n", wine_dbgstr_longlong(begin),
+           wine_dbgstr_longlong(end));
+        InterlockedExchangeAdd64(c, begin);
+    }
+
+    p_vcomp_for_dynamic_init_i8(flags, 1000, 0, 7, 5);
+    while (p_vcomp_for_dynamic_next_i8(&begin, &end))
+    {
+        ok(num_threads != 1 || (begin == 1000 && end == 0),
+           "expected begin == 1000 and end == 0, got %s and %s\n", wine_dbgstr_longlong(begin),
+           wine_dbgstr_longlong(end));
+        InterlockedExchangeAdd64(d, begin);
+    }
+}
+
 static void test_vcomp_for_dynamic_init(void)
 {
     static const int guided_a[] = {0, 6041, 9072, 11179};
@@ -1725,6 +1867,110 @@ static void test_vcomp_for_dynamic_init(void)
     pomp_set_num_threads(max_threads);
 }
 
+static void test_vcomp_for_dynamic_init_i8(void)
+{
+    static const int guided_a[] = {0, 6041, 9072, 11179};
+    static const int guided_b[] = {1000, 1959, 2928, 3821};
+    static const int guided_c[] = {0, 4067, 6139, 7273};
+    static const int guided_d[] = {1000, 1933, 2861, 3727};
+    LONG64 a, b, c, d;
+    int max_threads = pomp_get_max_threads();
+    int i;
+
+    /* test static scheduling */
+    for_dynamic_static_i8_cb();
+
+    for (i = 1; i <= 4; i++)
+    {
+        pomp_set_num_threads(i);
+        p_vcomp_fork(TRUE, 0, for_dynamic_static_i8_cb);
+        p_vcomp_fork(FALSE, 0, for_dynamic_static_i8_cb);
+    }
+
+    /* test chunked scheduling */
+    a = b = c = d = 0;
+    for_dynamic_chunked_i8_cb(&a, &b, &c, &d);
+    ok(a == 71071, "expected a == 71071, got %s\n", wine_dbgstr_longlong(a));
+    ok(b == 71929, "expected b == 71929, got %s\n", wine_dbgstr_longlong(b));
+    ok(c == 14210, "expected c == 14210, got %s\n", wine_dbgstr_longlong(c));
+    ok(d == 14790, "expected d == 14790, got %s\n", wine_dbgstr_longlong(d));
+
+    for (i = 1; i <= 4; i++)
+    {
+        pomp_set_num_threads(i);
+
+        a = b = c = d = 0;
+        p_vcomp_fork(TRUE, 4, for_dynamic_chunked_i8_cb, &a, &b, &c, &d);
+        ok(a == 71071, "expected a == 71071, got %s\n", wine_dbgstr_longlong(a));
+        ok(b == 71929, "expected b == 71929, got %s\n", wine_dbgstr_longlong(b));
+        ok(c == 14210, "expected c == 14210, got %s\n", wine_dbgstr_longlong(c));
+        ok(d == 14790, "expected d == 14790, got %s\n", wine_dbgstr_longlong(d));
+
+        a = b = c = d = 0;
+        p_vcomp_fork(FALSE, 4, for_dynamic_chunked_i8_cb, &a, &b, &c, &d);
+        ok(a == 71071, "expected a == 71071, got %s\n", wine_dbgstr_longlong(a));
+        ok(b == 71929, "expected b == 71929, got %s\n", wine_dbgstr_longlong(b));
+        ok(c == 14210, "expected c == 14210, got %s\n", wine_dbgstr_longlong(c));
+        ok(d == 14790, "expected d == 14790, got %s\n", wine_dbgstr_longlong(d));
+    }
+
+    /* test guided scheduling */
+    a = b = c = d = 0;
+    for_dynamic_guided_i8_cb(VCOMP_DYNAMIC_FLAGS_GUIDED, &a, &b, &c, &d);
+    ok(a == guided_a[0], "expected a == %d, got %s\n", guided_a[0], wine_dbgstr_longlong(a));
+    ok(b == guided_b[0], "expected b == %d, got %s\n", guided_b[0], wine_dbgstr_longlong(b));
+    ok(c == guided_c[0], "expected c == %d, got %s\n", guided_c[0], wine_dbgstr_longlong(c));
+    ok(d == guided_d[0], "expected d == %d, got %s\n", guided_d[0], wine_dbgstr_longlong(d));
+
+    for (i = 1; i <= 4; i++)
+    {
+        pomp_set_num_threads(i);
+
+        a = b = c = d = 0;
+        p_vcomp_fork(TRUE, 5, for_dynamic_guided_i8_cb, VCOMP_DYNAMIC_FLAGS_GUIDED, &a, &b, &c, &d);
+        ok(a == guided_a[i - 1], "expected a == %d, got %s\n", guided_a[i - 1], wine_dbgstr_longlong(a));
+        ok(b == guided_b[i - 1], "expected b == %d, got %s\n", guided_b[i - 1], wine_dbgstr_longlong(b));
+        ok(c == guided_c[i - 1], "expected c == %d, got %s\n", guided_c[i - 1], wine_dbgstr_longlong(c));
+        ok(d == guided_d[i - 1], "expected d == %d, got %s\n", guided_d[i - 1], wine_dbgstr_longlong(d));
+
+        a = b = c = d = 0;
+        p_vcomp_fork(FALSE, 5, for_dynamic_guided_i8_cb, VCOMP_DYNAMIC_FLAGS_GUIDED, &a, &b, &c, &d);
+        ok(a == guided_a[0], "expected a == %d, got %s\n", guided_a[0], wine_dbgstr_longlong(a));
+        ok(b == guided_b[0], "expected b == %d, got %s\n", guided_b[0], wine_dbgstr_longlong(b));
+        ok(c == guided_c[0], "expected c == %d, got %s\n", guided_c[0], wine_dbgstr_longlong(c));
+        ok(d == guided_d[0], "expected d == %d, got %s\n", guided_d[0], wine_dbgstr_longlong(d));
+    }
+
+    /* test with empty flags */
+    a = b = c = d = 0;
+    for_dynamic_guided_i8_cb(0, &a, &b, &c, &d);
+    ok(a == guided_a[0], "expected a == %d, got %s\n", guided_a[0], wine_dbgstr_longlong(a));
+    ok(b == guided_b[0], "expected b == %d, got %s\n", guided_b[0], wine_dbgstr_longlong(b));
+    ok(c == guided_c[0], "expected c == %d, got %s\n", guided_c[0], wine_dbgstr_longlong(c));
+    ok(d == guided_d[0], "expected d == %d, got %s\n", guided_d[0], wine_dbgstr_longlong(d));
+
+    for (i = 1; i <= 4; i++)
+    {
+        pomp_set_num_threads(i);
+
+        a = b = c = d = 0;
+        p_vcomp_fork(TRUE, 5, for_dynamic_guided_i8_cb, 0, &a, &b, &c, &d);
+        ok(a == guided_a[i - 1], "expected a == %d, got %s\n", guided_a[i - 1], wine_dbgstr_longlong(a));
+        ok(b == guided_b[i - 1], "expected b == %d, got %s\n", guided_b[i - 1], wine_dbgstr_longlong(b));
+        ok(c == guided_c[i - 1], "expected c == %d, got %s\n", guided_c[i - 1], wine_dbgstr_longlong(c));
+        ok(d == guided_d[i - 1], "expected d == %d, got %s\n", guided_d[i - 1], wine_dbgstr_longlong(d));
+
+        a = b = c = d = 0;
+        p_vcomp_fork(FALSE, 5, for_dynamic_guided_i8_cb, 0, &a, &b, &c, &d);
+        ok(a == guided_a[0], "expected a == %d, got %s\n", guided_a[0], wine_dbgstr_longlong(a));
+        ok(b == guided_b[0], "expected b == %d, got %s\n", guided_b[0], wine_dbgstr_longlong(b));
+        ok(c == guided_c[0], "expected c == %d, got %s\n", guided_c[0], wine_dbgstr_longlong(c));
+        ok(d == guided_d[0], "expected d == %d, got %s\n", guided_d[0], wine_dbgstr_longlong(d));
+    }
+
+    pomp_set_num_threads(max_threads);
+}
+
 static void CDECL master_cb(HANDLE semaphore)
 {
     int num_threads = pomp_get_num_threads();
@@ -2644,6 +2890,7 @@ START_TEST(vcomp)
     test_vcomp_for_static_simple_init();
     test_vcomp_for_static_init();
     test_vcomp_for_dynamic_init();
+    test_vcomp_for_dynamic_init_i8();
     test_vcomp_master_begin();
     test_vcomp_single_begin();
     test_vcomp_enter_critsect();
-- 
2.25.1




More information about the wine-devel mailing list