Skip to content

Commit

Permalink
- CPU only mode now possible without openCL (Thanks @harry1453)
Browse files Browse the repository at this point in the history
- added multi thread usage of ShabalLibrary if openCL disabled
  (https://github.com/burst-apps-team/libShabal)
- some cleanup
- updated lib versions
- new version 0.6.0
  • Loading branch information
de-luxe committed Mar 3, 2019
1 parent 3a58bcd commit 30a2033
Show file tree
Hide file tree
Showing 31 changed files with 313 additions and 661 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2018 by luxe - https://github.com/de-luxe - BURST-LUXE-RED2-G6JW-H4HG5
Copyright (c) 2015-2019 by luxe - https://github.com/de-luxe - BURST-LUXE-RED2-G6JW-H4HG5

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GPU assisted Proof of Capacity (PoC) Miner for Burstcoin (BURST)

1. edit 'jminer.properties' with text editor to configure miner
2. ensure java8 (64bit) and openCL driver/sdk is installed (java9 will not work)
3. execute 'java -jar -d64 -XX:+UseG1GC burstcoin-jminer-0.5.x-RELEASE.jar' or run the *.bat/*.sh file
3. execute 'java -jar -d64 -XX:+UseG1GC burstcoin-jminer-0.6.x-RELEASE.jar' or run the *.bat/*.sh file

> '-d64' to ensure 64bit java (remove for 32bit)
> '-XX:+UseG1GC' to free memory after round finished.
Expand Down Expand Up @@ -120,7 +120,7 @@ number of retries to get winner from walletServer

winnerRetriesOnAsync=10

### winnerRetryIntervalInMs (default:500)
### winnerRetryIntervalInMs (default:4000)
time to wait until next retry to get winner from walletServer

winnerRetryIntervalInMs=250
Expand Down Expand Up @@ -150,6 +150,13 @@ https://github.com/bhamon/gpuPlotGenerator/blob/master/README.md
You could also use that instruction to find your platformId and deviceId if needed.
Since version 0.4.4 all available platforms and devices are listed on startup.

### useOpenCl (default:true)
Since version 0.6.0 openCL is optional. Thanks harry1453!
Disable (useOpenCl=false) to only use CPU for mining.
Following settings are only relevant if openCL is used.

default=false

### platformId (default:0)
id of openCL platform on your system. one platform may have multiple
devices, the miner currently uses just one (in general not the bottleneck)
Expand Down
10 changes: 7 additions & 3 deletions jminer.default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# - BURSTCOIN JMINER --------- THIS IS EXPERIMENTAL SOFTWARE, USE ON YOUR OWN RISK! -
# -----------------------------------------------------------------------------------
# jminer is a PoC (Proof of Capacity) miner with GPU support for Burstcoin (BURST)
# (openCL will also work with CPU in needed)
# (openCL will also work with CPU if needed, alternative openCL can be disabled.)
#
# Requirements:
# - Java8 (64bit recommend to use more memory) DO NOT USE Java9/10!
Expand Down Expand Up @@ -93,7 +93,7 @@ dynamicTargetDeadline=
# winnerRetriesOnAsync - number of retries to get winner from walletServer
# (default:4)
# winnerRetryIntervalInMs - time to wait until next retry to get winner from walletServer
# (default:500)
# (default:4000)
# -----------------------------------------------------------------------------------
numericAccountId=xxxxxxxxxxxxxxx
poolServer=http://pool.com
Expand Down Expand Up @@ -124,13 +124,16 @@ passPhrase=xxxxxxxxxxxxxx
# https://github.com/bhamon/gpuPlotGenerator/blob/master/README.md
# You could also use that instruction to find your platformId and deviceId if needed.
#
# useOpenCl - disable (useOpenCl=false) to only use CPU for mining. Thanks harry1453!
# (default:true) Following settings are only relevant if openCL is used.
#
# platformId - id of openCL platform on your system. one platform may have multiple
# (default:0) devices, the miner currently uses just one (in general not the bottleneck)
#
# deviceId - specifies the device used by OCLCecker, can be your first GPU,
# (default:0) in most cases it will not be 100% used. (depends on capacity)
# -----------------------------------------------------------------------------------
useOpenCl=true
useOpenCl=
platformId=
deviceId=

Expand Down Expand Up @@ -203,6 +206,7 @@ showSkippedDeadlines=
# completely read ... depending on the power of your GPU.
# if staggersize is smaller than chunkPartNonces, staggersize will be used.
# e.g. play with +/- 160000 steps
# (value will be divided by 10 for CPU only mining!)
#
# readerThreads - normally '0' means, the miner takes one thread per drive (plotPath) this is recommend.
# (default:0) choosing a other number of 'readerThreads' can be useful on memory issues.
Expand Down
24 changes: 5 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>burstcoin</groupId>
<artifactId>burstcoin-jminer</artifactId>
<version>0.5.3-SNAPSHOT</version>
<version>0.6.0-RELEASE</version>
<packaging>jar</packaging>

<name>burstcoin-jminer</name>
Expand All @@ -14,21 +14,17 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<version>2.1.3.RELEASE</version>
<relativePath/>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>burstcoin.jminer.JMinerApplication</start-class>
<java.version>1.8</java.version>
<jocl-blast.version>1.3.0</jocl-blast.version>
<saphir-hash.version>3.0.3</saphir-hash.version>
<bcprov-jdk15on.version>1.60</bcprov-jdk15on.version>

<!-- only needed for older gpu -->
<!--<jocl.version>0.1.9</jocl.version>-->

<jocl-blast.version>1.5.0</jocl-blast.version>
<saphir-hash.version>3.0.5</saphir-hash.version>
<bcprov-jdk15on.version>1.61</bcprov-jdk15on.version>
</properties>

<dependencies>
Expand All @@ -43,14 +39,6 @@
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>

<!-- add for older gpu -->
<!--<dependency>-->
<!--<groupId>org.jocl</groupId>-->
<!--<artifactId>jocl</artifactId>-->
<!--<version>${jocl.version}</version>-->
<!--</dependency>-->

<!-- remove for older gpu -->
<dependency>
<groupId>org.jocl</groupId>
<artifactId>jocl-blast</artifactId>
Expand Down Expand Up @@ -87,10 +75,8 @@
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.2.0</version>
</dependency>


</dependencies>

<build>
Expand Down
2 changes: 1 addition & 1 deletion run.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java -jar -d64 -XX:+UseG1GC burstcoin-jminer-0.5.3-SNAPSHOT.jar
java -jar -d64 -XX:+UseG1GC burstcoin-jminer-0.6.0-RELEASE.jar
2 changes: 1 addition & 1 deletion src/main/java/burstcoin/jminer/JMinerCommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void run(String... args)
LOG.info(" __ __ GPU assisted PoC-Miner");
LOG.info(" |__| _____ |__| ____ ___________ ");
LOG.info(" version | |/ \\| |/ \\_/ __ \\_ __ \\");
LOG.info(" 0.5.3 | | Y Y \\ | | \\ ___/| | \\/");
LOG.info(" 0.6.0 | | Y Y \\ | | \\ ___/| | \\/");
LOG.info(" /\\__| |__|_| /__|___| /\\___ >__| ");
LOG.info(" \\______| \\/ \\/ \\/");
LOG.info(" mining engine: BURST-LUXE-RED2-G6JW-H4HG5");
Expand Down
28 changes: 7 additions & 21 deletions src/main/java/burstcoin/jminer/core/CoreConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

package burstcoin.jminer.core;

import burstcoin.jminer.core.checker.util.LowestNonceFinder;
import burstcoin.jminer.core.checker.util.OCLChecker;
import burstcoin.jminer.core.checker.util.ShaLibChecker;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.ssl.SslContextFactory;
Expand All @@ -43,13 +40,13 @@
@ComponentScan(basePackages = {"burstcoin.jminer.core"})
public class CoreConfig
{
private static final Logger logger = LoggerFactory.getLogger(CoreConfig.class);
private static final Logger LOG = LoggerFactory.getLogger(CoreConfig.class);

@Bean(name = "readerPool")
public ThreadPoolTaskExecutor readerPool()
{
ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
pool.setThreadPriority(Thread.NORM_PRIORITY);
pool.setThreadPriority(Thread.MIN_PRIORITY);
// false-> triggers interrupt exception at shutdown
pool.setWaitForTasksToCompleteOnShutdown(true);
pool.initialize();
Expand All @@ -60,14 +57,17 @@ public ThreadPoolTaskExecutor readerPool()
public SimpleAsyncTaskExecutor networkPool()
{
SimpleAsyncTaskExecutor pool = new SimpleAsyncTaskExecutor();
pool.setThreadPriority(Thread.NORM_PRIORITY + 1);
pool.setThreadPriority(Thread.NORM_PRIORITY);
return pool;
}

@Bean
public HttpClient httpClient()
{
HttpClient client = new HttpClient(new SslContextFactory(true));
SslContextFactory sslContextFactory = new SslContextFactory(null);
sslContextFactory.setEndpointIdentificationAlgorithm("none");

HttpClient client = new HttpClient(sslContextFactory);
try
{
client.start();
Expand All @@ -84,18 +84,4 @@ public ObjectMapper objectMapper()
{
return new ObjectMapper();
}

@Bean
public LowestNonceFinder getLowestNonceFinder() {
if (CoreProperties.getUseOpenCl()) {
return new OCLChecker();
} else {
try {
return new ShaLibChecker();
} catch (Exception | LinkageError e) {
logger.warn("Error initialising Shabal Library, falling back to OpenCL", e);
return new OCLChecker();
}
}
}
}
6 changes: 2 additions & 4 deletions src/main/java/burstcoin/jminer/core/CoreProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class CoreProperties
private static final int DEFAULT_REFRESH_INTERVAL = 2000;
private static final int DEFAULT_CONNECTION_TIMEOUT = 18000;
private static final int DEFAULT_WINNER_RETRIES_ON_ASYNC = 4;
private static final int DEFAULT_WINNER_RETRY_INTERVAL_IN_MS = 500;
private static final int DEFAULT_WINNER_RETRY_INTERVAL_IN_MS = 4000;
private static final boolean DEFAULT_SCAN_PATHS_EVERY_ROUND = true;
private static final boolean DEFAULT_BYTE_UNIT_DECIMAL = true;
private static final boolean DEFAULT_LIST_PLOT_FILES = false;
Expand Down Expand Up @@ -100,11 +100,9 @@ public class CoreProperties
private static Boolean byteUnitDecimal;
private static Boolean listPlotFiles;
private static Boolean showDriveInfo;
private static Boolean recommitDeadlines;
private static Boolean showSkippedDeadlines;
private static Integer readerThreads;
private static Boolean writeLogFile;
private static Boolean triggerServer;
private static Boolean debug;
private static String logFilePath;
private static String logPatternFile;
Expand Down Expand Up @@ -350,7 +348,7 @@ public static String getPassPhrase()
*
* @return use open cl
*/
public static boolean getUseOpenCl()
public static boolean isUseOpenCl()
{
if(useOpenCl == null)
{
Expand Down
18 changes: 7 additions & 11 deletions src/main/java/burstcoin/jminer/core/checker/Checker.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,18 @@

package burstcoin.jminer.core.checker;

import burstcoin.jminer.core.CoreProperties;
import burstcoin.jminer.core.checker.event.CheckerResultEvent;
import burstcoin.jminer.core.checker.util.LowestNonceFinder;
import burstcoin.jminer.core.checker.util.OCLChecker;
import burstcoin.jminer.core.checker.util.ShaLibChecker;
import burstcoin.jminer.core.reader.event.ReaderLoadedPartEvent;
import fr.cryptohash.Shabal256;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Scope;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import pocminer.generate.MiningPlot;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLong;

Expand All @@ -51,17 +47,17 @@ public class Checker
private static final Logger LOG = LoggerFactory.getLogger(Checker.class);

private final ApplicationEventPublisher publisher;
private final LowestNonceFinder lowestNonceFinder;
private final OCLChecker oclChecker;

// data
private volatile AtomicLong blockNumber;
private volatile byte[] generationSignature;

@Autowired
public Checker(ApplicationEventPublisher publisher, LowestNonceFinder lowestNonceFinder)
public Checker(ApplicationEventPublisher publisher, OCLChecker oclChecker)
{
this.publisher = publisher;
this.lowestNonceFinder = lowestNonceFinder;
this.oclChecker = oclChecker;

blockNumber = new AtomicLong();
}
Expand All @@ -75,12 +71,12 @@ public void reconfigure(long blockNumber, byte[] generationSignature)
@EventListener
public void handleMessage(ReaderLoadedPartEvent event)
{
if(blockNumber.get() == event.getBlockNumber() && Arrays.equals(generationSignature, event.getGenerationSignature()))
if(CoreProperties.isUseOpenCl() && blockNumber.get() == event.getBlockNumber() && Arrays.equals(generationSignature, event.getGenerationSignature()))
{
int lowestNonce;
synchronized(lowestNonceFinder)
synchronized(oclChecker)
{
lowestNonce = lowestNonceFinder.findLowest(event.getGenerationSignature(), event.getScoops());
lowestNonce = oclChecker.findLowest(event.getGenerationSignature(), event.getScoops());
}
if(blockNumber.get() == event.getBlockNumber() && Arrays.equals(generationSignature, event.getGenerationSignature()))
{
Expand Down

This file was deleted.

13 changes: 8 additions & 5 deletions src/main/java/burstcoin/jminer/core/checker/util/OCLChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
import org.jocl.cl_mem;
import org.jocl.cl_platform_id;
import org.jocl.cl_program;
import org.jocl.cl_queue_properties;
import org.jocl.utils.DeviceInfos;
import org.jocl.utils.Devices;
import org.jocl.utils.PlatformInfos;
import org.jocl.utils.Platforms;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
Expand All @@ -54,7 +54,8 @@
/**
* Org. OCLChecker code and the used openCL kernels are provided by 'burst dev'. Please donate: BURST-QHCJ-9HB5-PTGC-5Q8J9
*/
public class OCLChecker implements LowestNonceFinder {
@Component
public class OCLChecker {
private static final Logger LOG = LoggerFactory.getLogger(OCLChecker.class);

private static final int SIZE_DIVISOR = CoreProperties.isByteUnitDecimal() ? 1000 : 1024;
Expand All @@ -72,7 +73,10 @@ public class OCLChecker implements LowestNonceFinder {
@PostConstruct
protected void postConstruct()
{
initChecker(CoreProperties.getPlatformId(), CoreProperties.getDeviceId());
if(CoreProperties.isUseOpenCl())
{
initChecker(CoreProperties.getPlatformId(), CoreProperties.getDeviceId());
}
}

public void initChecker(int platformId, int deviceId)
Expand Down Expand Up @@ -107,7 +111,7 @@ public void initChecker(int platformId, int deviceId)
contextProperties.addProperty(CL_CONTEXT_PLATFORM, platforms[platformId]);

context = clCreateContext(contextProperties, 1, new cl_device_id[]{devices[deviceId]}, null, null, null);
queue = clCreateCommandQueue(context, devices[deviceId], 0, null);
queue = clCreateCommandQueueWithProperties(context, devices[deviceId], new cl_queue_properties(), null);

String kernelSource;
try
Expand Down Expand Up @@ -192,7 +196,6 @@ private String bytesAsGigabyte(long bytes)
return bytes / SIZE_DIVISOR / SIZE_DIVISOR / SIZE_DIVISOR % SIZE_DIVISOR + "" + G_UNIT;
}

@Override
public int findLowest(byte[] gensig, byte[] data)
{
cl_mem dataMem, deadlineMem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import com.sun.jna.Native;
import pocminer.generate.MiningPlot;

public class ShaLibChecker implements LowestNonceFinder {
public class ShaLibChecker {

private final ShabalLibrary shabalLibrary;

public ShaLibChecker() {
shabalLibrary = Native.load("libshabal", ShabalLibrary.class);
shabalLibrary = Native.loadLibrary("libshabal", ShabalLibrary.class);
shabalLibrary.shabal_init();
}

Expand All @@ -18,7 +18,6 @@ private interface ShabalLibrary extends Library {
void shabal_init();
}

@Override
public int findLowest(byte[] gensig, byte[] data) {
return (int) shabalLibrary.shabal_findBestDeadline(data, data.length / MiningPlot.SCOOP_SIZE, gensig);
}
Expand Down
Loading

0 comments on commit 30a2033

Please sign in to comment.