Skip to content

Commit

Permalink
Pretty demo gpusolver case
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Feb 19, 2024
1 parent f71712d commit a3856e5
Showing 1 changed file with 13 additions and 28 deletions.
41 changes: 13 additions & 28 deletions src/main/java/de/nqueensfaf/Demo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,27 @@ public static void main(String[] args) {
gpu();
}

// static void cpu() {
// new CpuSolver()
// .setPresetQueens(5)
// .setThreadCount(1)
// .setUpdateInterval(800)
// .onInit(self -> System.out.println("Starting Solver for board size " + self.getN() + "..."))
// .onUpdate((self, progress, solutions, duration) -> System.out.println("progress: " + progress + " solutions: " + solutions + " duration: " + duration))
// .onFinish(self -> System.out.println("Found " + self.getSolutions() + " solutions in " + self.getDuration() + " ms"))
// .setN(16)
// .solve();
// }
static void cpu() {
new CpuSolver()
.setPresetQueens(5)
.setThreadCount(1)
.setUpdateInterval(800)
.onInit(self -> System.out.println("Starting Solver for board size " + self.getN() + "..."))
.onUpdate((self, progress, solutions, duration) -> System.out.println("progress: " + progress + " solutions: " + solutions + " duration: " + duration))
.onFinish(self -> System.out.println("Found " + self.getSolutions() + " solutions in " + self.getDuration() + " ms"))
.setN(16)
.solve();
}

static void gpu() {
GpuSolver g = new GpuSolver();
List<GpuInfo> availableGpus = g.getAvailableGpus();
for(var gpu : availableGpus) {
if(gpu.vendor().toLowerCase().contains("nvidia")) {
g.gpuSelection().add(gpu.id(), 5, 64);
} else {
g.gpuSelection().add(gpu.id(), 50, 24);
}
}
g.gpuSelection().choose(availableGpus.get(0).id());
g.setUpdateInterval(400);
g.onInit(self -> System.out.println("Starting Solver for board size " + self.getN() + "..."))
.onUpdate((self, progress, solutions, duration) -> System.out.println("progress: " + progress + " solutions: " + solutions + " duration: " + duration))
.onFinish(self -> System.out.println("Found " + self.getSolutions() + " solutions in " + self.getDuration() + " ms"))
.setN(20)
.setN(18)
.solve();

// new GPUSolver()
// .setPresetQueens(6)
// .setUpdateInterval(200)
// .onInit(self -> System.out.println("Starting Solver for board size " + self.getN() + "..."))
// .onUpdate((self, progress, solutions, duration) -> System.out.println("progress: " + progress + " solutions: " + solutions + " duration: " + duration))
// .onFinish(self -> System.out.println("Found " + self.getSolutions() + " solutions in " + self.getDuration() + " ms"))
// .setN(18)
// .solve();
}
}

0 comments on commit a3856e5

Please sign in to comment.