--- a/tools/tilegap/tilegap2.c +++ b/tools/tilegap/tilegap2.c @@ -42,6 +42,7 @@ typedef struct { uint64_t survivors; uint64_t bestGap, bestGapI1, bestGapJ, bestGapCount, bestGapMinPos; + uint64_t bestPos[64]; int nBestPos; /* ALL positions attaining the max (<=64), chunk-local */ uint64_t bestRun, bestRunI1, bestRunJ; uint64_t candidates, overflow; char pad[64]; @@ -174,8 +175,10 @@ uint64_t gap = S[oi2] - S[oi1]; if (gap >= r->bestGap) { uint64_t gpos = S[oi1] + j * Pv; - if (gap > r->bestGap) { r->bestGap = gap; r->bestGapI1 = oi1; r->bestGapJ = j; r->bestGapCount = 1; r->bestGapMinPos = gpos; } - else { r->bestGapCount++; if (gpos < r->bestGapMinPos) r->bestGapMinPos = gpos; } } + if (gap > r->bestGap) { r->bestGap = gap; r->bestGapI1 = oi1; r->bestGapJ = j; r->bestGapCount = 1; r->bestGapMinPos = gpos; r->nBestPos = 0; } + else { r->bestGapCount++; if (gpos < r->bestGapMinPos) r->bestGapMinPos = gpos; } + if (r->nBestPos < 64) r->bestPos[r->nBestPos++] = gpos; + else fprintf(stderr, "WARN thread %d: >64 maxima, position list truncated\n", L->tid); } if (run > r->bestRun) { r->bestRun = run; r->bestRunI1 = oi1; r->bestRunJ = j; } } } @@ -283,6 +286,12 @@ printf("G2(b#) = %llu at pos %llu (i=%llu j=%llu)\n", (unsigned long long)bg, (unsigned long long)(S[bi1] + bj * Pv), (unsigned long long)bi1, (unsigned long long)bj); printf("maxima: count=%llu least position = %llu\n", (unsigned long long)gc, (unsigned long long)gm); + { uint64_t mpos[1024]; int nm = 0; + for (int t = 0; t < NT; t++) if (R[t].bestGap == bg) + for (int k = 0; k < R[t].nBestPos && nm < 1024; k++) mpos[nm++] = R[t].bestPos[k]; + printf("maxima positions (%d):", nm); + for (int k = 0; k < nm; k++) printf(" %llu", (unsigned long long)mpos[k]); + printf("\n"); } printf("max dead run of T_v slots = %llu at pos %llu\n", (unsigned long long)br, (unsigned long long)(S[ri1] + rj * Pv)); uint64_t alltiles = (WD + (uint64_t)WT - 1) / (uint64_t)WT; uint64_t hi = (THI < alltiles) ? THI : alltiles;