From 2c291aed4bb80f07e8557284d3399cf1e2a4ccb9 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 1 Mar 2026 18:09:44 +0100 Subject: Improve Windows build support. - Use multithreading (works with a sufficiently recent version of the Microsoft developer tools / C SDK). - Detect CPU architecture and use AVX2 or NEON when appropriate. - Automatically detect python installation path. --- src/solvers/distribution.h | 10 +++++----- src/solvers/h48/distribution_h48.h | 10 +++++----- src/solvers/h48/gendata_h48.h | 14 +++++++------- src/solvers/h48/solve.h | 12 ++++++------ 4 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src/solvers') diff --git a/src/solvers/distribution.h b/src/solvers/distribution.h index e9302da..78b9b5e 100644 --- a/src/solvers/distribution.h +++ b/src/solvers/distribution.h @@ -10,13 +10,13 @@ typedef struct { const unsigned char *table; } getdistribution_data_t; -STATIC void *getdistribution_runthread(void *); +STATIC wrapthread_return_t getdistribution_runthread(void *); STATIC void getdistribution(const unsigned char *, uint64_t [static INFO_DISTRIBUTION_LEN], const tableinfo_t [static 1]); STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); -STATIC void * +STATIC wrapthread_return_t getdistribution_runthread(void *arg) { getdistribution_data_t *data = (getdistribution_data_t *)arg; @@ -33,7 +33,7 @@ getdistribution_runthread(void *arg) for (j = 0; j < ENTRIES_PER_BYTE(k); j++) data->distr[(table[i] & (m << (j*k))) >> (j*k)]++; - return NULL; + return wrapthread_return_val; } STATIC void @@ -60,12 +60,12 @@ getdistribution( .distr = local_distr[i], .table = table, }; - wrapthread_create(&thread[i], NULL, + wrapthread_create(&thread[i], getdistribution_runthread, &targ[i]); } for (i = 0; i < THREADS; i++) - wrapthread_join(thread[i], NULL); + wrapthread_join(thread[i]); memset(distr, 0, INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); for (i = 0; i < THREADS; i++) diff --git a/src/solvers/h48/distribution_h48.h b/src/solvers/h48/distribution_h48.h index 93a6933..80c946e 100644 --- a/src/solvers/h48/distribution_h48.h +++ b/src/solvers/h48/distribution_h48.h @@ -4,11 +4,11 @@ needed for H48 because of the intertwined fallback table, and it is easier to have some duplication than to make these functions needlessly generic. */ -STATIC void *getdistribution_h48_runthread(void *); +STATIC wrapthread_return_t getdistribution_h48_runthread(void *); STATIC void getdistribution_h48(const unsigned char *, uint64_t [static INFO_DISTRIBUTION_LEN], const tableinfo_t [static 1]); -STATIC void * +STATIC wrapthread_return_t getdistribution_h48_runthread(void *arg) { getdistribution_data_t *data = (getdistribution_data_t *)arg; @@ -33,7 +33,7 @@ getdistribution_h48_runthread(void *arg) data->distr[(t & (m << (3*k))) >> (3*k)]--; } - return NULL; + return wrapthread_return_val; } STATIC void @@ -58,12 +58,12 @@ getdistribution_h48( .distr = local_distr[i], .table = table, }; - wrapthread_create(&thread[i], NULL, + wrapthread_create(&thread[i], getdistribution_h48_runthread, &targ[i]); } for (i = 0; i < THREADS; i++) - wrapthread_join(thread[i], NULL); + wrapthread_join(thread[i]); memset(distr, 0, INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); for (i = 0; i < THREADS; i++) diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index ef8a854..b37bcfb 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h @@ -3,7 +3,7 @@ STATIC long long gendata_h48_dispatch( STATIC uint64_t gendata_h48short(gendata_h48short_arg_t [static 1]); STATIC int64_t gendata_h48(gendata_h48_arg_t [static 1]); STATIC void gendata_h48_maintable(gendata_h48_arg_t [static 1]); -STATIC void *gendata_h48_runthread(void *); +STATIC wrapthread_return_t gendata_h48_runthread(void *); STATIC_INLINE void gendata_h48_mark(gendata_h48_mark_t [static 1]); STATIC_INLINE bool gendata_h48_dfs_stop( @@ -230,9 +230,9 @@ gendata_h48_maintable(gendata_h48_arg_t arg[static 1]) inext = 0; count = 0; - wrapthread_mutex_init(&shortcubes_mutex, NULL); + wrapthread_mutex_init(&shortcubes_mutex); for (i = 0; i < CHUNKS; i++) - wrapthread_mutex_init(&table_mutex[i], NULL); + wrapthread_mutex_init(&table_mutex[i]); for (i = 0; i < THREADS; i++) { dfsarg[i] = (h48_dfs_arg_t){ .h = arg->h, @@ -251,7 +251,7 @@ gendata_h48_maintable(gendata_h48_arg_t arg[static 1]) dfsarg[i].table_mutex[ii] = &table_mutex[ii]; wrapthread_create( - &thread[i], NULL, gendata_h48_runthread, &dfsarg[i]); + &thread[i], gendata_h48_runthread, &dfsarg[i]); } if (NISSY_CANSLEEP) { @@ -281,7 +281,7 @@ gendata_h48_maintable(gendata_h48_arg_t arg[static 1]) } for (i = 0; i < THREADS; i++) - wrapthread_join(thread[i], NULL); + wrapthread_join(thread[i]); h48map_destroy(&shortcubes); @@ -291,7 +291,7 @@ gendata_h48_maintable(gendata_h48_arg_t arg[static 1]) writetableinfo(&arg->info, bufsize, (unsigned char *)arg->h48buf); } -STATIC void * +STATIC wrapthread_return_t gendata_h48_runthread(void *arg) { uint64_t coord, coordext, coordmin; @@ -328,7 +328,7 @@ gendata_h48_runthread(void *arg) } } - return NULL; + return wrapthread_return_val; } STATIC void diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 15ac6ea..4fd0aea 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h @@ -78,7 +78,7 @@ STATIC_INLINE void h48_prune_restore_inverse(const h48_prune_t [static 1], STATIC int64_t solve_h48_maketasks( dfsarg_solve_h48_t [static 1], dfsarg_solve_h48_maketasks_t [static 1], solve_h48_task_t [static H48_STARTING_CUBES], int [static 1]); -STATIC void *solve_h48_runthread(void *); +STATIC wrapthread_return_t solve_h48_runthread(void *); STATIC int64_t solve_h48_dfs(dfsarg_solve_h48_t [static 1]); STATIC void solve_h48_log_solutions(solution_list_t [static 1], size_t); STATIC int solve_h48_compare_tasks(const void *, const void *); @@ -383,7 +383,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1]) return ret; } -STATIC void * +STATIC wrapthread_return_t solve_h48_runthread(void *arg) { int i, j; @@ -445,7 +445,7 @@ solve_h48_runthread(void *arg) solve_h48_runthread_end: dfsarg->thread_done = true; - return NULL; + return wrapthread_return_val; } STATIC int64_t @@ -638,7 +638,7 @@ solve_h48( } - wrapthread_mutex_init(&solutions_mutex, NULL); + wrapthread_mutex_init(&solutions_mutex); mtarg = (dfsarg_solve_h48_maketasks_t) { .cube = oc.cube, @@ -689,7 +689,7 @@ solve_h48( arg[i].target_depth = d; arg[i].thread_done = false; wrapthread_create( - &thread[i], NULL, solve_h48_runthread, &arg[i]); + &thread[i], solve_h48_runthread, &arg[i]); } /* Log solutions and handle pause / stop / resume */ @@ -718,7 +718,7 @@ solve_h48( } for (i = 0; i < threads; i++) - wrapthread_join(thread[i], NULL); + wrapthread_join(thread[i]); solve_h48_log_solutions(&sollist, lastused); lastused = sollist.used; -- cgit v1.3