Skip to content

Commit

Permalink
#19 - 115s 32 batch
Browse files Browse the repository at this point in the history
  • Loading branch information
obriensystems committed Jan 1, 2025
1 parent f4a657f commit 4347cd6
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,19 @@ public void searchCollatzParallel(long oddSearchCurrent, long secondsStart) {
long path = 0L;
long maxValue = 1L;


long batchBits = 5; // adjust this based on the chip architecture

long searchBits = 32;
long batchBits = 5;
long batches = 1 << batchBits;
long threadBits = searchBits - batchBits;
long threads = 1 << threadBits;
for (long part = 0; part < batches ; part++) {
for (long part = 0; part < (batches + 1) ; part++) {

// generate a limited collection for the search space - 32 is a good
System.out.println("Searching: " + searchBits + " space, batch " + part + " of "
+ batches + " with " + threadBits +" bits of " + threads + " threads" );
List<Long> oddNumbers = LongStream.range(1L + (part * threads), (1 + part) * threads)
List<Long> oddNumbers = LongStream.range(1L + (part * threads), ((1 + part) * threads) - 1)
.boxed()
.collect(Collectors.toList());

Expand All @@ -98,6 +99,7 @@ public void searchCollatzParallel(long oddSearchCurrent, long secondsStart) {

results.stream().sorted().forEach(x -> System.out.println(x));
}
System.out.println("last number: " + ((1 + (batches) * threads) - 1));
}

public static void main(String[] args) {
Expand Down

0 comments on commit 4347cd6

Please sign in to comment.