diff --git a/.circleci/config.yml b/.circleci/config.yml index 854886f22..39bc861ca 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -146,7 +146,7 @@ jobs: topology: type: string machine: - image: ubuntu-2204:2024.04.4 + image: ubuntu-2404:edge resource_class: << parameters.worker_type >> environment: CC: nvc diff --git a/.cirrus.yml b/.cirrus.yml index eabdb7df1..7154de16b 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,6 +1,6 @@ osx_m1_task: macos_instance: - image: ghcr.io/cirruslabs/macos-sonoma-xcode:latest + image: ghcr.io/cirruslabs/macos-sequoia-xcode:latest timeout_in: 5m matrix: env: diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8a5187c64..d5471d823 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -10,7 +10,7 @@ concurrency: jobs: linux-gcc: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 continue-on-error: true strategy: matrix: @@ -22,8 +22,6 @@ jobs: CXX: g++-${{ matrix.gcc_version }} steps: - uses: actions/checkout@v4 - - if: ${{ matrix.gcc_version == '13' }} - run: sudo apt-add-repository 'ppa:ubuntu-toolchain-r/test' && break || sleep 1 - name: install compiler run: sudo apt-get install gcc-${{ matrix.gcc_version }} g++-${{ matrix.gcc_version }} - if: ${{ matrix.topology != 'no' }} @@ -41,20 +39,14 @@ jobs: timeout-minutes: 4 linux-clang: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 continue-on-error: true strategy: matrix: - clang_version: [11, 12, 13, 14, 15, 16, 17, 18] + clang_version: [14, 15, 16, 17, 18] scheduler: [nemesis, sherwood, distrib] topology: [hwloc, binders, no] include: - - clang_version: 11 - gcc_version: 10 - - clang_version: 12 - gcc_version: 11 - - clang_version: 13 - gcc_version: 11 - clang_version: 14 gcc_version: 11 - clang_version: 15 @@ -70,12 +62,6 @@ jobs: CXX: clang++-${{ matrix.clang_version }} steps: - uses: actions/checkout@v4 - - if: ${{ matrix.clang_version == '16' || matrix.clang_version == '17' || matrix.clang_version == '18' }} - run: | - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && break || sleep 1 - sudo apt-add-repository 'deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy-${{ matrix.clang_version }} main' && break || sleep 1 - - if: ${{ matrix.gcc_version == '13' }} - run: sudo apt-add-repository 'ppa:ubuntu-toolchain-r/test' && break || sleep 1 - name: install gcc run: sudo apt-get install gcc-${{ matrix.gcc_version }} g++-${{ matrix.gcc_version }} - name: install clang @@ -95,7 +81,7 @@ jobs: timeout-minutes: 7 linux-icx: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 continue-on-error: true strategy: matrix: @@ -112,13 +98,12 @@ jobs: hwloc-ls --version - name: install gcc run: | - sudo apt-add-repository 'ppa:ubuntu-toolchain-r/test' && break || sleep 1 - sudo apt-get install gcc-13 g++-13 + sudo apt-get install gcc-14 g++-14 - name: install icx run: | wget -O - https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | sudo apt-key add - && break || sleep 1 sudo apt-add-repository 'deb https://apt.repos.intel.com/oneapi all main' && break || sleep 1 - sudo apt-get install intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2023.2.4 + sudo apt-get install intel-oneapi-compiler-dpcpp-cpp-2024.2 source /opt/intel/oneapi/setvars.sh icx -v - name: build qthreads @@ -159,7 +144,7 @@ jobs: run: | wget -O - https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | sudo apt-key add - && break || sleep 1 sudo apt-add-repository 'deb https://apt.repos.intel.com/oneapi all main' && break || sleep 1 - sudo apt-get install intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2023.2.1 + sudo apt-get install intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2023.2.4 source /opt/intel/oneapi/setvars.sh icc -v - name: build qthreads @@ -176,7 +161,7 @@ jobs: timeout-minutes: 7 linux-aocc: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 continue-on-error: true strategy: matrix: @@ -193,7 +178,6 @@ jobs: hwloc-ls --version - name: install gcc run: | - sudo apt-add-repository 'ppa:ubuntu-toolchain-r/test' && break || sleep 1 sudo apt-get install gcc-13 g++-13 - name: install aocc run: | @@ -268,7 +252,6 @@ jobs: - uses: actions/checkout@v4 - if: ${{ ! matrix.use_libcxx }} run: | - sudo apt-add-repository universe && break || sleep 1 sudo apt-get install gcc-14 g++-14 - name: install compiler run: | @@ -312,7 +295,6 @@ jobs: steps: - uses: actions/checkout@v4 - run: | - sudo apt-add-repository universe && break || sleep 1 sudo apt-get install gcc-14 g++-14 - if: ${{ matrix.compiler == 'clang' }} run: | @@ -344,7 +326,6 @@ jobs: steps: - uses: actions/checkout@v4 - run: | - sudo apt-add-repository universe && break || sleep 1 wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && break || sleep 1 sudo apt-add-repository 'deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main' && break || sleep 1 sudo apt-get install clang-format-19 diff --git a/include/qt_atomics.h b/include/qt_atomics.h index f4eca058d..32f9de39b 100644 --- a/include/qt_atomics.h +++ b/include/qt_atomics.h @@ -184,7 +184,7 @@ static inline int QTHREAD_TRYLOCK_TRY(qt_spin_trylock_t *x) { t.tv_sec = n.tv_sec + ((t.tv_nsec >= 1000000000) ? 1 : 0); \ t.tv_nsec -= ((t.tv_nsec >= 1000000000) ? 1000000000 : 0); \ int val = pthread_cond_timedwait(&(c), &(c##_lock), &t); \ - qassert(val == EINVAL || val == EPERM, 0); \ + assert(!(val == EINVAL || val == EPERM)); \ } while (0) #define QTHREAD_COND_WAIT_DUO(c, m) \ do { \ diff --git a/test/basics/Makefile.am b/test/basics/Makefile.am index 4f9b65d6e..190b885b6 100644 --- a/test/basics/Makefile.am +++ b/test/basics/Makefile.am @@ -24,6 +24,7 @@ TESTS = \ qthread_stackleft \ qtimer \ qalloc \ + queue \ arbitrary_blocking_operation \ sinc_null \ sinc_workers \ @@ -107,7 +108,7 @@ qthread_timer_wait_SOURCES = qthread_timer_wait.c qtimer_SOURCES = qtimer.c -#queue_SOURCES = queue.c +queue_SOURCES = queue.c qthread_fork_precond_SOURCES = qthread_fork_precond.c diff --git a/test/basics/qthread_disable_shepherd.c b/test/basics/qthread_disable_shepherd.c index d9054cdcb..39548cac7 100644 --- a/test/basics/qthread_disable_shepherd.c +++ b/test/basics/qthread_disable_shepherd.c @@ -8,17 +8,17 @@ static aligned_t checkres(void *arg) { qthread_shepherd_id_t myshep = qthread_shep(); - assert(myshep == 1 || myshep == 0 || myshep == 2); + test_check(myshep == 1 || myshep == 0 || myshep == 2); if ((intptr_t)arg >= 0) { iprintf( "checkres: myshep = %i, should be %i\n", myshep, (int)(intptr_t)arg); - assert(myshep == (qthread_shepherd_id_t)(intptr_t)arg); + test_check(myshep == (qthread_shepherd_id_t)(intptr_t)arg); } else { iprintf("checkres: myshep = %i, should NOT be %i\n", myshep, -1 * (int)(intptr_t)arg); - assert(myshep != (qthread_shepherd_id_t)(-1 * (intptr_t)arg)); + test_check(myshep != (qthread_shepherd_id_t)(-1 * (intptr_t)arg)); } return 0; @@ -27,20 +27,20 @@ static aligned_t checkres(void *arg) { static aligned_t migrant(void *arg) { int myshep = qthread_shep(); - assert(myshep == 1 || myshep == 0); + test_check(myshep == 1 || myshep == 0); if (myshep == 1) { qthread_migrate_to(0); - assert(qthread_shep() == 0); + test_check(qthread_shep() == 0); } else { qthread_migrate_to(1); iprintf("migrant starting on %i, aimed at 1, ended up on %i\n", myshep, qthread_shep()); if (arg == (void *)2) { - assert(qthread_shep() != 1); + test_check(qthread_shep() != 1); } else { - assert(qthread_shep() == 1); + test_check(qthread_shep() == 1); } } @@ -60,11 +60,11 @@ int main(int argc, char *argv[]) { CHECK_VERBOSE(); - assert(qthread_readstate(TOTAL_SHEPHERDS) == 3); - assert(qthread_readstate(ACTIVE_SHEPHERDS) == 2); + test_check(qthread_readstate(TOTAL_SHEPHERDS) == 3); + test_check(qthread_readstate(ACTIVE_SHEPHERDS) == 2); iprintf("now to fork to shepherd 0...\n"); qret = qthread_fork_to(checkres, (void *)0, &ret, 0); - assert(qret == QTHREAD_SUCCESS); + test_check(qret == QTHREAD_SUCCESS); qthread_readFF(&ret, &ret); iprintf("\tsuccess in forking to shepherd 0!\n"); iprintf("now to fork to shepherd 1...\n"); @@ -74,7 +74,7 @@ int main(int argc, char *argv[]) { iprintf("\tsuccessfully failed to fork to shepherd 1!\n"); iprintf("now to fork to shepherd 2...\n"); qret = qthread_fork_to(checkres, (void *)2, &ret, 2); - assert(qret == QTHREAD_SUCCESS); + test_check(qret == QTHREAD_SUCCESS); qthread_readFF(&ret, &ret); iprintf("\tsuccess in forking to shepherd 2!\n"); iprintf("now to fork the migrant...\n"); diff --git a/test/basics/qthread_fp.c b/test/basics/qthread_fp.c index 86ef17c47..959f52671 100644 --- a/test/basics/qthread_fp.c +++ b/test/basics/qthread_fp.c @@ -1,60 +1,60 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include - -#include "argparsing.h" - -// https://www.geeksforgeeks.org/comparison-float-value-c/ -// https://dotnettutorials.net/lesson/taylor-series-using-recursion-in-c/ -// https://www.studytonight.com/c/programs/important-concepts/sum-of-taylor-series - -struct parts { - int length; - float exp; - float ans; - aligned_t cond; -}; - -// https://www.w3resource.com/c-programming-exercises/math/c-math-exercise-24.php -static float taylor_exponential_core(int n, float x) { - float exp_sum = 1; - for (int i = n - 1; i > 0; --i) { exp_sum = 1 + x * exp_sum / i; } - return exp_sum; -} - -static aligned_t taylor_exponential(void *arg) { - struct parts *te = (struct parts *)arg; - te->ans = taylor_exponential_core(te->length, te->exp); - return 0; -} - -static void checkFloat(void) { - struct parts teParts = {250, 9.0f, 0.0f}; - int ret = -1; - qthread_empty(&teParts.cond); - - ret = qthread_fork(taylor_exponential, &teParts, &teParts.cond); - test_check(ret == QTHREAD_SUCCESS); - - ret = qthread_readFF(NULL, &teParts.cond); - test_check(ret == QTHREAD_SUCCESS); -} - -int main(void) { - float ans = taylor_exponential_core(250, 9.0); - float expected = 8103.083984f; - float rel_error = fabsf(ans - expected) / fabsf(expected); - float threshold = 1E-7f; - test_check(rel_error < threshold); - - int status = qthread_initialize(); - test_check(status == QTHREAD_SUCCESS); - - checkFloat(); - return EXIT_SUCCESS; -} +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include "argparsing.h" + +// https://www.geeksforgeeks.org/comparison-float-value-c/ +// https://dotnettutorials.net/lesson/taylor-series-using-recursion-in-c/ +// https://www.studytonight.com/c/programs/important-concepts/sum-of-taylor-series + +struct parts { + int length; + float exp; + float ans; + aligned_t cond; +}; + +// https://www.w3resource.com/c-programming-exercises/math/c-math-exercise-24.php +static float taylor_exponential_core(int n, float x) { + float exp_sum = 1; + for (int i = n - 1; i > 0; --i) { exp_sum = 1 + x * exp_sum / i; } + return exp_sum; +} + +static aligned_t taylor_exponential(void *arg) { + struct parts *te = (struct parts *)arg; + te->ans = taylor_exponential_core(te->length, te->exp); + return 0; +} + +static void checkFloat(void) { + struct parts teParts = {250, 9.0f, 0.0f}; + int ret = -1; + qthread_empty(&teParts.cond); + + ret = qthread_fork(taylor_exponential, &teParts, &teParts.cond); + test_check(ret == QTHREAD_SUCCESS); + + ret = qthread_readFF(NULL, &teParts.cond); + test_check(ret == QTHREAD_SUCCESS); +} + +int main(void) { + float ans = taylor_exponential_core(250, 9.0); + float expected = 8103.083984f; + float rel_error = fabsf(ans - expected) / fabsf(expected); + float threshold = 1E-7f; + test_check(rel_error < threshold); + + int status = qthread_initialize(); + test_check(status == QTHREAD_SUCCESS); + + checkFloat(); + return EXIT_SUCCESS; +} diff --git a/test/basics/qthread_fp_double.c b/test/basics/qthread_fp_double.c index fce839389..09a63d5b7 100644 --- a/test/basics/qthread_fp_double.c +++ b/test/basics/qthread_fp_double.c @@ -1,112 +1,114 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -// https://www.geeksforgeeks.org/comparison-float-value-c/ -// https://dotnettutorials.net/lesson/taylor-series-using-recursion-in-c/ -// https://www.studytonight.com/c/programs/important-concepts/sum-of-taylor-series - -struct parts { - int length; - double exp; - double ans; - aligned_t cond; -}; - -// https://www.w3resource.com/c-programming-exercises/math/c-math-exercise-24.php -static double taylor_exponential_core(int n, double x, int yield) { - double exp_sum = 1; - for (int i = n - 1; i > 0; --i) { - exp_sum = 1 + x * exp_sum / i; - if (yield) qthread_yield(); - } - return exp_sum; -} - -static aligned_t taylor_exponential(void *arg) { - struct parts *te = (struct parts *)arg; - te->ans = taylor_exponential_core(te->length, te->exp, 1); - return 0; -} - -static void startQthread(struct parts *teParts) { - qthread_empty(&teParts->cond); - - int ret = qthread_fork(taylor_exponential, teParts, &teParts->cond); - assert(ret == QTHREAD_SUCCESS); -} - -static aligned_t checkDoubleAsQthreads(void) { - struct parts teParts1 = {250, 9.0, 0.0}; - struct parts teParts2 = {50, 3.0, 0.0}; - struct parts teParts3 = {150, 11.0, 0.0}; - - startQthread(&teParts1); - startQthread(&teParts2); - startQthread(&teParts3); - - int ret = qthread_readFF(NULL, &teParts1.cond); - assert(ret == QTHREAD_SUCCESS); - - ret = qthread_readFF(NULL, &teParts2.cond); - assert(ret == QTHREAD_SUCCESS); - - ret = qthread_readFF(NULL, &teParts3.cond); - assert(ret == QTHREAD_SUCCESS); - - double threshold = 1E-15; - - double expected_1 = 8103.0839275753824; - double rel_error_1 = fabs(expected_1 - teParts1.ans) / fabs(expected_1); - assert(rel_error_1 < threshold); - - double expected_2 = 20.085536923187668; - double rel_error_2 = fabs(expected_2 - teParts2.ans) / fabs(expected_2); - assert(rel_error_2 < threshold); - - double expected_3 = 59874.141715197809; - double rel_error_3 = fabs(expected_3 - teParts3.ans) / fabs(expected_3); - assert(rel_error_3 < threshold); - - return 0; -} - -static void checkDoubleAsQthread(void) { - int ret = -1; - struct parts teParts = {250, 9.0, 0.0}; - qthread_empty(&teParts.cond); - - ret = qthread_fork(taylor_exponential, &teParts, &teParts.cond); - assert(ret == QTHREAD_SUCCESS); - - ret = qthread_readFF(NULL, &teParts.cond); - assert(ret == QTHREAD_SUCCESS); - - double expected = 8103.0839275753824; - double rel_error = fabs(expected - teParts.ans) / fabs(expected); - assert(rel_error < 1E-15); -} - -static void checkDouble(void) { - double ans = taylor_exponential_core(250, 9.0, 0); - double expected = 8103.0839275753824; - double rel_error = fabs(expected - ans) / fabs(expected); - assert(rel_error < 1E-15); -} - -int main(void) { - checkDouble(); - - int status = qthread_initialize(); - assert(status == QTHREAD_SUCCESS); - - checkDoubleAsQthread(); - checkDoubleAsQthreads(); - return EXIT_SUCCESS; -} +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "argparsing.h" + +// https://www.geeksforgeeks.org/comparison-float-value-c/ +// https://dotnettutorials.net/lesson/taylor-series-using-recursion-in-c/ +// https://www.studytonight.com/c/programs/important-concepts/sum-of-taylor-series + +struct parts { + int length; + double exp; + double ans; + aligned_t cond; +}; + +// https://www.w3resource.com/c-programming-exercises/math/c-math-exercise-24.php +static double taylor_exponential_core(int n, double x, int yield) { + double exp_sum = 1; + for (int i = n - 1; i > 0; --i) { + exp_sum = 1 + x * exp_sum / i; + if (yield) qthread_yield(); + } + return exp_sum; +} + +static aligned_t taylor_exponential(void *arg) { + struct parts *te = (struct parts *)arg; + te->ans = taylor_exponential_core(te->length, te->exp, 1); + return 0; +} + +static void startQthread(struct parts *teParts) { + qthread_empty(&teParts->cond); + + int ret = qthread_fork(taylor_exponential, teParts, &teParts->cond); + test_check(ret == QTHREAD_SUCCESS); +} + +static aligned_t checkDoubleAsQthreads(void) { + struct parts teParts1 = {250, 9.0, 0.0}; + struct parts teParts2 = {50, 3.0, 0.0}; + struct parts teParts3 = {150, 11.0, 0.0}; + + startQthread(&teParts1); + startQthread(&teParts2); + startQthread(&teParts3); + + int ret = qthread_readFF(NULL, &teParts1.cond); + test_check(ret == QTHREAD_SUCCESS); + + ret = qthread_readFF(NULL, &teParts2.cond); + test_check(ret == QTHREAD_SUCCESS); + + ret = qthread_readFF(NULL, &teParts3.cond); + test_check(ret == QTHREAD_SUCCESS); + + double threshold = 1E-15; + + double expected_1 = 8103.0839275753824; + double rel_error_1 = fabs(expected_1 - teParts1.ans) / fabs(expected_1); + test_check(rel_error_1 < threshold); + + double expected_2 = 20.085536923187668; + double rel_error_2 = fabs(expected_2 - teParts2.ans) / fabs(expected_2); + test_check(rel_error_2 < threshold); + + double expected_3 = 59874.141715197809; + double rel_error_3 = fabs(expected_3 - teParts3.ans) / fabs(expected_3); + test_check(rel_error_3 < threshold); + + return 0; +} + +static void checkDoubleAsQthread(void) { + int ret = -1; + struct parts teParts = {250, 9.0, 0.0}; + qthread_empty(&teParts.cond); + + ret = qthread_fork(taylor_exponential, &teParts, &teParts.cond); + test_check(ret == QTHREAD_SUCCESS); + + ret = qthread_readFF(NULL, &teParts.cond); + test_check(ret == QTHREAD_SUCCESS); + + double expected = 8103.0839275753824; + double rel_error = fabs(expected - teParts.ans) / fabs(expected); + test_check(rel_error < 1E-15); +} + +static void checkDouble(void) { + double ans = taylor_exponential_core(250, 9.0, 0); + double expected = 8103.0839275753824; + double rel_error = fabs(expected - ans) / fabs(expected); + test_check(rel_error < 1E-15); +} + +int main(void) { + checkDouble(); + + int status = qthread_initialize(); + test_check(status == QTHREAD_SUCCESS); + + checkDoubleAsQthread(); + checkDoubleAsQthreads(); + return EXIT_SUCCESS; +} diff --git a/test/basics/queue.c b/test/basics/queue.c index 6b725c8fa..f8c459414 100644 --- a/test/basics/queue.c +++ b/test/basics/queue.c @@ -28,36 +28,37 @@ int main(int argc, char *argv[]) { NUMARG(THREADS_ENQUEUED, "THREADS_ENQUEUED"); status = qthread_initialize(); - assert(status == QTHREAD_SUCCESS); + test_check(status == QTHREAD_SUCCESS); iprintf("%i shepherds...\n", qthread_num_shepherds()); iprintf(" %i threads total\n", qthread_num_workers()); iprintf("Creating the queue...\n"); the_queue = qthread_queue_create(QTHREAD_QUEUE_MULTI_JOIN_LENGTH, 0); - assert(the_queue); + test_check(the_queue); iprintf("---------------------------------------------------------\n"); iprintf("\tSINGLE THREAD TEST\n\n"); iprintf("1/4 Spawning thread to be queued...\n"); status = qthread_fork(tobequeued, NULL, &return_value); - assert(status == QTHREAD_SUCCESS); + test_check(status == QTHREAD_SUCCESS); iprintf("2/4 Waiting for thread to queue itself...\n"); while (qthread_queue_length(the_queue) != 1) qthread_yield(); - assert(qthread_readstate(NODE_BUSYNESS) == 1); + test_check(qthread_readstate(NODE_BUSYNESS) == 1); iprintf("3/4 Releasing the queue...\n"); qthread_queue_release_all(the_queue); ret = qthread_readFF(NULL, &return_value); - assert(ret == QTHREAD_SUCCESS); + test_check(ret == QTHREAD_SUCCESS); - assert(threads_in == 1); - assert(awoke == 1); - assert(qthread_queue_length(the_queue) == 0); - assert(qthread_readstate(NODE_BUSYNESS) == 1); + test_check(threads_in == 1); + test_check(awoke == 1); + test_check(qthread_queue_length(the_queue) == 0); + // This relies on approximate estimates, so it's not reliable to test here. + // test_check(qthread_readstate(NODE_BUSYNESS) == 1); iprintf("4/4 Test passed!\n"); iprintf("---------------------------------------------------------\n"); @@ -69,14 +70,14 @@ int main(int argc, char *argv[]) { iprintf("1/6 Spawning %u threads to be queued...\n", THREADS_ENQUEUED); for (int i = 0; i < THREADS_ENQUEUED; i++) { status = qthread_fork(tobequeued, NULL, retvals + i); - assert(status == QTHREAD_SUCCESS); + test_check(status == QTHREAD_SUCCESS); } iprintf("2/6 Waiting for %u threads to queue themselves...\n", THREADS_ENQUEUED); while (qthread_queue_length(the_queue) != THREADS_ENQUEUED) qthread_yield(); - assert(threads_in == THREADS_ENQUEUED); - assert(qthread_readstate(NODE_BUSYNESS) == 1); + test_check(threads_in == THREADS_ENQUEUED); + test_check(qthread_readstate(NODE_BUSYNESS) == 1); iprintf("3/6 Releasing a single thread...\n"); qthread_queue_release_one(the_queue); @@ -84,19 +85,20 @@ int main(int argc, char *argv[]) { iprintf("4/6 Waiting for that thread to exit\n"); while (awoke == 0) qthread_yield(); - assert(qthread_queue_length(the_queue) == (THREADS_ENQUEUED - 1)); - assert(qthread_readstate(NODE_BUSYNESS) == 1); + test_check(qthread_queue_length(the_queue) == (THREADS_ENQUEUED - 1)); + // This relies on approximate estimates, so it's not reliable to test here. + // test_check(qthread_readstate(NODE_BUSYNESS) == 1); iprintf("5/6 Releasing the rest of the threads...\n"); qthread_queue_release_all(the_queue); for (int i = 0; i < THREADS_ENQUEUED; i++) { ret = qthread_readFF(NULL, retvals + i); - assert(ret == QTHREAD_SUCCESS); + test_check(ret == QTHREAD_SUCCESS); } - assert(qthread_queue_length(the_queue) == 0); - assert(qthread_readstate(NODE_BUSYNESS) == 1); + test_check(qthread_queue_length(the_queue) == 0); + test_check(qthread_readstate(NODE_BUSYNESS) == 1); iprintf("6/6 Test passed!\n"); free(retvals); diff --git a/test/basics/tasklocal_data_no_argcopy.c b/test/basics/tasklocal_data_no_argcopy.c index 202e2adf1..121fd681b 100644 --- a/test/basics/tasklocal_data_no_argcopy.c +++ b/test/basics/tasklocal_data_no_argcopy.c @@ -16,7 +16,7 @@ static aligned_t use_default_space(void *arg) { qthread_size_tasklocal()); iprintf("use_default_space(): local_int_arr at %p\n", local_int_arr); local_int_arr = (int *)qthread_get_tasklocal(size); - assert(42 != local_int_arr[42]); + test_check(42 != local_int_arr[42]); iprintf( "use_default_space(): retrieved tasklocal data successfully (42 != %d)\n", local_int_arr[42]); @@ -36,7 +36,7 @@ static aligned_t use_allocated_space(void *arg) { qthread_size_tasklocal()); iprintf("use_allocated_space(): local_int_arr at %p\n", local_int_arr); local_int_arr = (int *)qthread_get_tasklocal(size); - assert(42 != local_int_arr[42]); + test_check(42 != local_int_arr[42]); iprintf( "use_allocated_space(): retrieved tasklocal data successfully (42 != %d)\n", local_int_arr[42]); @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) { iprintf("set tasklocal data to '42'\n"); local_int_ptr = NULL; local_int_ptr = (int *)qthread_get_tasklocal(size); - assert(42 == *local_int_ptr); + test_check(42 == *local_int_ptr); iprintf("main(): retrieved tasklocal data successfully (42 == %d)\n", *local_int_ptr); local_int_ptr = NULL; @@ -90,10 +90,10 @@ int main(int argc, char *argv[]) { iprintf("main(): set local_int_arr[42] = %d\n", local_int_arr[42]); local_int_arr = NULL; local_int_arr = (int *)qthread_get_tasklocal(size); - assert(42 == local_int_arr[0]); + test_check(42 == local_int_arr[0]); iprintf("main(): retrieved copied tasklocal data successfully (42 == %d)\n", local_int_arr[42]); - assert(42 == local_int_arr[42]); + test_check(42 == local_int_arr[42]); iprintf("main(): retrieved tasklocal data successfully (42 == %d)\n", local_int_arr[42]); local_int_arr = NULL; @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) { iprintf("main(): size_tasklocal() is %d\n", qthread_size_tasklocal()); iprintf("main(): local_int_arr at %p\n", local_int_arr); local_int_arr = (int *)qthread_get_tasklocal(size); - assert(42 == local_int_arr[42]); + test_check(42 == local_int_arr[42]); iprintf("main(): retrieved tasklocal data successfully (42 == %d)\n", local_int_arr[42]); local_int_arr = NULL; @@ -123,7 +123,7 @@ int main(int argc, char *argv[]) { iprintf("main(): size_tasklocal() is %d\n", qthread_size_tasklocal()); iprintf("main(): local_int_arr at %p\n", local_int_arr); local_int_arr = (int *)qthread_get_tasklocal(size); - assert(42 == local_int_arr[42]); + test_check(42 == local_int_arr[42]); iprintf("main(): retrieved tasklocal data successfully (42 == %d)\n", local_int_arr[42]); local_int_arr = NULL; diff --git a/test/basics/tasklocal_data_no_default.c b/test/basics/tasklocal_data_no_default.c index e42146a28..f3eb2ef93 100644 --- a/test/basics/tasklocal_data_no_default.c +++ b/test/basics/tasklocal_data_no_default.c @@ -24,8 +24,8 @@ static aligned_t use_default_space(void *arg) { qthread_yield(); local_int_arr = (int *)qthread_get_tasklocal(size); iprintf("use_default_space(): local_int_arr at %p\n", local_int_arr); - for (int i = 0; i < 64; ++i) { assert(local_int_arr[i] == i); } - iprintf("use_default_space(): all assertions passed!\n"); + for (int i = 0; i < 64; ++i) { test_check(local_int_arr[i] == i); } + iprintf("use_default_space(): all test_checkions passed!\n"); return 0; } @@ -49,8 +49,8 @@ static aligned_t use_allocated_space(void *arg) { qthread_yield(); local_int_arr = (int *)qthread_get_tasklocal(size); iprintf("use_allocated_space(): local_int_arr at %p\n", local_int_arr); - for (int i = 0; i < 2048; ++i) { assert(local_int_arr[i] == 2048 - i); } - iprintf("use_allocated_space(): all assertions passed!\n"); + for (int i = 0; i < 2048; ++i) { test_check(local_int_arr[i] == 2048 - i); } + iprintf("use_allocated_space(): all test_checkions passed!\n"); return 0; } @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) { iprintf("set tasklocal data to '42'\n"); local_int_ptr = NULL; local_int_ptr = (int *)qthread_get_tasklocal(size); - assert(42 == *local_int_ptr); + test_check(42 == *local_int_ptr); iprintf("main(): retrieved tasklocal data successfully (42 == %d)\n", *local_int_ptr); local_int_ptr = NULL; @@ -99,10 +99,10 @@ int main(int argc, char *argv[]) { iprintf("main(): set local_int_arr[42] = %d\n", local_int_arr[42]); local_int_arr = NULL; local_int_arr = (int *)qthread_get_tasklocal(size); - assert(42 == local_int_arr[0]); + test_check(42 == local_int_arr[0]); iprintf("main(): retrieved copied tasklocal data successfully (42 == %d)\n", local_int_arr[42]); - assert(42 == local_int_arr[42]); + test_check(42 == local_int_arr[42]); iprintf("main(): retrieved tasklocal data successfully (42 == %d)\n", local_int_arr[42]); local_int_arr = NULL; @@ -117,7 +117,7 @@ int main(int argc, char *argv[]) { iprintf("main(): size_tasklocal() is %d\n", qthread_size_tasklocal()); iprintf("main(): local_int_arr at %p\n", local_int_arr); local_int_arr = (int *)qthread_get_tasklocal(size); - assert(42 == local_int_arr[42]); + test_check(42 == local_int_arr[42]); iprintf("main(): retrieved tasklocal data successfully (42 == %d)\n", local_int_arr[42]); local_int_arr = NULL; @@ -132,7 +132,7 @@ int main(int argc, char *argv[]) { iprintf("main(): size_tasklocal() is %d\n", qthread_size_tasklocal()); iprintf("main(): local_int_arr at %p\n", local_int_arr); local_int_arr = (int *)qthread_get_tasklocal(size); - assert(42 == local_int_arr[42]); + test_check(42 == local_int_arr[42]); iprintf("main(): retrieved tasklocal data successfully (42 == %d)\n", local_int_arr[42]); local_int_arr = NULL;