diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-19 08:12:14 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-19 08:12:14 +0200 |
| commit | b848b089edb6d8c9b0bd10b46926f76547aa99c3 (patch) | |
| tree | 54acaab0fea0218bd9a25b8866d17f7fba1038e1 /src/solvers | |
| parent | 8bc74cde8f6bfb4b264bb3399681e7e04ec1e703 (diff) | |
| download | nissy-core-b848b089edb6d8c9b0bd10b46926f76547aa99c3.tar.gz nissy-core-b848b089edb6d8c9b0bd10b46926f76547aa99c3.zip | |
Fixed data race
Diffstat (limited to 'src/solvers')
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index 6f87685..2a62b1d 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -433,7 +433,7 @@ gendata_h48k2_return_size: | |||
| 433 | STATIC void * | 433 | STATIC void * |
| 434 | gendata_h48k2_runthread(void *arg) | 434 | gendata_h48k2_runthread(void *arg) |
| 435 | { | 435 | { |
| 436 | uint64_t count, c; | 436 | uint64_t count, coord, mutex; |
| 437 | kvpair_t kv; | 437 | kvpair_t kv; |
| 438 | h48k2_dfs_arg_t *dfsarg; | 438 | h48k2_dfs_arg_t *dfsarg; |
| 439 | 439 | ||
| @@ -454,10 +454,11 @@ gendata_h48k2_runthread(void *arg) | |||
| 454 | LOG("Processing %" PRIu64 "th short cube\n", count); | 454 | LOG("Processing %" PRIu64 "th short cube\n", count); |
| 455 | 455 | ||
| 456 | if (kv.val < dfsarg->shortdepth) { | 456 | if (kv.val < dfsarg->shortdepth) { |
| 457 | c = kv.key >> (int64_t)(11 - dfsarg->h); | 457 | coord = kv.key >> (int64_t)(11 - dfsarg->h); |
| 458 | pthread_mutex_lock(dfsarg->table_mutex[c % CHUNKS]); | 458 | mutex = H48_INDEX(coord, dfsarg->k) % CHUNKS; |
| 459 | set_h48_pval(dfsarg->table, c, dfsarg->k, 0); | 459 | pthread_mutex_lock(dfsarg->table_mutex[mutex]); |
| 460 | pthread_mutex_unlock(dfsarg->table_mutex[c % CHUNKS]); | 460 | set_h48_pval(dfsarg->table, coord, dfsarg->k, 0); |
| 461 | pthread_mutex_unlock(dfsarg->table_mutex[mutex]); | ||
| 461 | } else { | 462 | } else { |
| 462 | dfsarg->cube = invcoord_h48(kv.key, dfsarg->crep, 11); | 463 | dfsarg->cube = invcoord_h48(kv.key, dfsarg->crep, 11); |
| 463 | gendata_h48k2_dfs(dfsarg); | 464 | gendata_h48k2_dfs(dfsarg); |
| @@ -530,16 +531,17 @@ STATIC_INLINE void | |||
| 530 | gendata_h48k2_mark(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg) | 531 | gendata_h48k2_mark(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg) |
| 531 | { | 532 | { |
| 532 | uint8_t oldval, newval; | 533 | uint8_t oldval, newval; |
| 533 | int64_t coord, fullcoord; | 534 | int64_t coord, fullcoord, mutex; |
| 534 | 535 | ||
| 535 | FOREACH_H48SIM(cube, arg->cocsepdata, arg->selfsim, | 536 | FOREACH_H48SIM(cube, arg->cocsepdata, arg->selfsim, |
| 536 | fullcoord = coord_h48(cube, arg->cocsepdata, 11); | 537 | fullcoord = coord_h48(cube, arg->cocsepdata, 11); |
| 537 | coord = fullcoord >> (int64_t)(11 - arg->h); | 538 | coord = fullcoord >> (int64_t)(11 - arg->h); |
| 538 | pthread_mutex_lock(arg->table_mutex[coord % CHUNKS]); | 539 | mutex = H48_INDEX(coord, arg->k) % CHUNKS; |
| 540 | pthread_mutex_lock(arg->table_mutex[mutex]); | ||
| 539 | oldval = get_h48_pval(arg->table, coord, arg->k); | 541 | oldval = get_h48_pval(arg->table, coord, arg->k); |
| 540 | newval = (uint8_t)MAX(depth, 0); | 542 | newval = (uint8_t)MAX(depth, 0); |
| 541 | set_h48_pval(arg->table, coord, arg->k, MIN(oldval, newval)); | 543 | set_h48_pval(arg->table, coord, arg->k, MIN(oldval, newval)); |
| 542 | pthread_mutex_unlock(arg->table_mutex[coord % CHUNKS]); | 544 | pthread_mutex_unlock(arg->table_mutex[mutex]); |
| 543 | ) | 545 | ) |
| 544 | } | 546 | } |
| 545 | 547 | ||
