From f66294f6b1a00d744de2128e873678ef74620d66 Mon Sep 17 00:00:00 2001 From: Michael OBrien Date: Fri, 5 Jan 2024 21:44:06 -0500 Subject: [PATCH] #11 - add to hierarchy --- .../collatz/server/ForkJoinCollatzServer.java | 2 +- .../server/ForkJoinCollatzServerStatic8.java | 64 +++++++++++++++++++ .../collatz/server/ForkJoinUnitOfWork.java | 12 ++-- 3 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 org.obrienscience.concurrent.CollatzBeowulfSE/src/main/java/org/obrienscience/collatz/server/ForkJoinCollatzServerStatic8.java diff --git a/org.obrienscience.concurrent.CollatzBeowulfSE/src/main/java/org/obrienscience/collatz/server/ForkJoinCollatzServer.java b/org.obrienscience.concurrent.CollatzBeowulfSE/src/main/java/org/obrienscience/collatz/server/ForkJoinCollatzServer.java index c1d85b9..7792689 100644 --- a/org.obrienscience.concurrent.CollatzBeowulfSE/src/main/java/org/obrienscience/collatz/server/ForkJoinCollatzServer.java +++ b/org.obrienscience.concurrent.CollatzBeowulfSE/src/main/java/org/obrienscience/collatz/server/ForkJoinCollatzServer.java @@ -4,7 +4,7 @@ import java.util.concurrent.ForkJoinPool; public class ForkJoinCollatzServer { - private ForkJoinPool mapReducePool; + protected ForkJoinPool mapReducePool; public void compute(long pool, long threads, long uowSplit, long extent) { BigInteger maxPath = BigInteger.ONE; diff --git a/org.obrienscience.concurrent.CollatzBeowulfSE/src/main/java/org/obrienscience/collatz/server/ForkJoinCollatzServerStatic8.java b/org.obrienscience.concurrent.CollatzBeowulfSE/src/main/java/org/obrienscience/collatz/server/ForkJoinCollatzServerStatic8.java new file mode 100644 index 0000000..347bb96 --- /dev/null +++ b/org.obrienscience.concurrent.CollatzBeowulfSE/src/main/java/org/obrienscience/collatz/server/ForkJoinCollatzServerStatic8.java @@ -0,0 +1,64 @@ +package org.obrienscience.collatz.server; + +import java.math.BigInteger; +import java.util.concurrent.ForkJoinPool; + +/** + * @author fmichaelobrien@google.com + */ +public class ForkJoinCollatzServerStatic8 extends ForkJoinCollatzServer { + + @Override + public void compute(long pool, long threads, long uowSplit, long extent) { + BigInteger maxPath = BigInteger.ONE; + BigInteger maxValue = BigInteger.ONE; + ForkJoinUnitOfWork forkJoinUOW = new ForkJoinUnitOfWork(uowSplit, 0, extent, maxPath, maxValue); + long startTime = System.currentTimeMillis(); + // create a pool of threads to the power of pool * # of (proc + ht) + mapReducePool = new ForkJoinPool(1 << pool);//Runtime.getRuntime().availableProcessors() << pool); + mapReducePool.invoke(forkJoinUOW); + long endTime = System.currentTimeMillis(); + System.out.println(new StringBuffer( + String.valueOf(endTime - startTime)).append(",") + .append(pool).append(",") + .append(threads).append(",") + .append(String.valueOf((endTime - startTime) / 1000)) + .append(threads).append(",").append(uowSplit).toString()); + } + + public static void main(String[] args) { + System.out.println("ForkJoinUnitOfWork8 (v 20240101)"); + long poolStart = 1; + long poolEnd = 1; + long runs = 1; + /* + if(null != args && args.length > 0) { + poolStart = Long.parseLong(args[0]); + } + if(null != args && args.length > 1) { + poolEnd = Long.parseLong(args[1]); + } + if(null != args && args.length > 2) { + runs = Long.parseLong(args[2]); + } */ + System.out.println("availableProc\t: " + Runtime.getRuntime().availableProcessors()); + //System.out.println("fjps threads\t: " + poolStart + "," + poolEnd); + System.out.println("freeMemory()\t: " + Runtime.getRuntime().freeMemory()); + System.out.println("maxMemory()\t: " + Runtime.getRuntime().maxMemory()); + System.out.println("totalMemory()\t: " + Runtime.getRuntime().totalMemory()); + System.out.println("System.getEnv()\t: " + System.getenv().toString()); + ForkJoinCollatzServerStatic8 server = new ForkJoinCollatzServerStatic8(); + long extent = 4;//25; + + + System.out.println("Range: bits\t: " + extent); + //for(long r=0;r