Skip to content

Commit

Permalink
initial project version
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirkic7 committed Oct 5, 2014
0 parents commit b7043b9
Show file tree
Hide file tree
Showing 14 changed files with 6,523 additions and 0 deletions.
75 changes: 75 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
CFLAGS=-D_FILE_OFFSET_BITS=64

linux64: plot plotavx2 optimize mine mine_pool_all mine_pool_share

linux32: plot32 optimize32 mine32 mine_pool_all32 mine_pool_share32

win64: optimize.exe

all: linux64 linux32

dist: linux64 linux32 win64
rm -f bin/* shabal64.o shabal32.o dcct_miner.tgz
mv plot plotavx2 optimize mine mine_pool_all plot32 optimize32 mine32 mine_pool_all32 mine_pool_share mine_pool_share32 optimize.exe bin
cp mine_uray.sh mine_dev_v1.sh mine_dev_v2.sh bin
tar -czf dcct_miner.tgz *

optimize.exe: optimize.c
x86_64-w64-mingw32-gcc-4.8 -D_FILE_OFFSET_BITS=64 -Wall -m64 -O2 -o optimize.exe optimize.c

plot: plot.c shabal64.o helper64.o mshabal_sse4.o
gcc -Wall -m64 -O2 -o plot plot.c shabal64.o helper64.o mshabal_sse4.o -march=native -lpthread -std=gnu99

plotavx2: plot.c shabal64.o helper64.o mshabal_sse4.o mshabal256_avx2.o
gcc -Wall -m64 -O2 -o plotavx2 plot.c shabal64.o helper64.o mshabal_sse4.o mshabal256_avx2.o -march=native -lpthread -std=gnu99 -DAVX2

mine: mine.c shabal64.o helper64.o
gcc -Wall -m64 -O2 -DSOLO -o mine mine.c shabal64.o helper64.o -lpthread

mine_pool_all: mine.c shabal64.o helper64.o
gcc -Wall -m64 -O2 -DURAY_POOL -o mine_pool_all mine.c shabal64.o helper64.o -lpthread

mine_pool_share: mine.c shabal64.o helper64.o
gcc -Wall -m64 -O2 -DSHARE_POOL -o mine_pool_share mine.c shabal64.o helper64.o -lpthread

optimize: optimize.c helper64.o
gcc -Wall -m64 -O2 -o optimize optimize.c helper64.o

plot32: plot.c shabal32.o helper32.o mshabal_sse432.o
gcc -Wall -m32 -O2 -o plot32 plot.c shabal32.o helper32.o mshabal_sse432.o -lpthread

mine32: mine.c shabal32.o helper32.o
gcc -Wall -m32 -O2 -DSOLO -o mine32 mine.c shabal32.o helper32.o -lpthread

mine_pool_all32: mine.c shabal32.o helper32.o
gcc -Wall -m32 -O2 -DURAY_POOL -o mine_pool_all32 mine.c shabal32.o helper32.o -lpthread

mine_pool_share32: mine.c shabal32.o helper32.o
gcc -Wall -m32 -O2 -DSHARE_POOL -o mine_pool_share32 mine.c shabal32.o helper32.o -lpthread

optimize32: optimize.c helper32.o
gcc -Wall -m32 -O2 -o optimize32 optimize.c helper32.o

helper64.o: helper.c
gcc -Wall -m64 -c -O2 -o helper64.o helper.c

helper32.o: helper.c
gcc -Wall -m32 -c -O2 -o helper32.o helper.c

shabal64.o: shabal64.s
gcc -Wall -m64 -c -O2 -o shabal64.o shabal64.s

shabal32.o: shabal32.s
gcc -Wall -m32 -c -o shabal32.o shabal32.s

mshabal_sse4.o: mshabal_sse4.c
gcc -Wall -m64 -c -O2 -march=native -o mshabal_sse4.o mshabal_sse4.c

mshabal256_avx2.o: mshabal256_avx2.c
gcc -Wall -m64 -c -O2 -march=native -mavx2 -o mshabal256_avx2.o mshabal256_avx2.c

mshabal_sse432.o: mshabal_sse4.c
gcc -Wall -m32 -c -O2 -march=native -o mshabal_sse432.o mshabal_sse4.c

clean:
rm -f mshabal_sse432.o mshabal_sse4.o mshabal256_avx2.o shabal64.o shabal32.o helper64.o helper32.o plot plotavx2 plot32 optimize optimize32 mine mine32 mine_pool_all mine_pool_all32 mine_pool_share mine_pool_share32 helper32.o helper64.o optimize.exe dcct_miner.tgz
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#MDCCT
=============
Linux BURST coin plot generator optimized for SSE4 / AVX2<br>
Speed gainx ov ~2x using SSE4 core instead of original<br>
<br>
Linux BURST coin miner/optimizer (untouched original code)<br>
Author: Niksa Franceschi <[email protected]>
Burst for donations: BURST-RQW7-3HNW-627D-3GAEV<br>

Orignal code for Linux miner/plotter/plot optimizer by dcct / Markus Tervooren <[email protected]>, Burst: BURST-R5LP-KEL9-UYLG-GFG6T<br>

Modifed using Cerr Janror <[email protected]>, Burst: BURST-LNVN-5M4L-S9KP-H5AAC, BurstSoftware code: https://github.com/BurstTools/BurstSoftware <br>

###Installing
> git clone https://github.com/BurstTools/BurstSoftware.git
> cd mdcct
> make
Installation may break on AVX2 code (depending on compiler), but it is separate binary.

###Usage
######For SSE4
> Usage: ./plot -k KEY [ -x CORE ] [-d DIRECTORY] [-s STARTNONCE] [-n NONCES] [-m STAGGERSIZE] [-t THREADS]
> CORE:
> 0 - default core
> 1 - SSE4 core
######For AVX2
>Usage: ./plotavx2 -k KEY [ -x CORE ] [-d DIRECTORY] [-s STARTNONCE] [-n NONCES] [-m STAGGERSIZE] [-t THREADS]
> CORE:
> 0 - default core
> 1 - SSE4 core
> 2 - AVX2 core
Not specifying -x option will default to original dcct ploter


119 changes: 119 additions & 0 deletions helper.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#include <string.h>
#include <stdio.h>


#ifdef _WIN32
#include <windows.h>
#elif MACOS
#include <sys/param.h>
#include <sys/sysctl.h>
#else
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/statvfs.h>
#endif

// Following 2 routines taken from: http://stackoverflow.com/questions/1557400/hex-to-char-array-in-c
int xdigit( char digit ){
int val;
if( '0' <= digit && digit <= '9' ) val = digit -'0';
else if( 'a' <= digit && digit <= 'f' ) val = digit -'a'+10;
else if( 'A' <= digit && digit <= 'F' ) val = digit -'A'+10;
else val = -1;
return val;
}

int xstr2strr(char *buf, unsigned bufsize, const char *in) {
if( !in ) return -1; // missing input string

unsigned inlen=strlen(in);
if( inlen%2 != 0 ) inlen--; // hex string must even sized

unsigned int i,j;
for(i=0; i<inlen; i++ )
if( xdigit(in[i])<0 ) return -3; // bad character in hex string

if( !buf || bufsize<inlen/2+1 ) return -4; // no buffer or too small

for(i=0,j=0; i<inlen; i+=2,j++ )
buf[j] = xdigit(in[i])*16 + xdigit(in[i+1]);

buf[inlen/2] = '\0';
return inlen/2+1;
}
// END (taken from)

// Detect number of CPUs (by Dirk-Jan Kroon)

int getNumberOfCores() {
#ifdef WIN32
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors;
#elif MACOS
int nm[2];
size_t len = 4;
uint32_t count;

nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
sysctl(nm, 2, &count, &len, NULL, 0);

if(count < 1) {
nm[1] = HW_NCPU;
sysctl(nm, 2, &count, &len, NULL, 0);
if(count < 1) { count = 1; }
}
return count;
#else
return sysconf(_SC_NPROCESSORS_ONLN);
#endif
}

// From http://www.binarytides.com/hostname-to-ip-address-c-sockets-linux/
int hostname_to_ip(char * hostname , char* ip) {
struct hostent *he;
struct in_addr **addr_list;
int i;

if ( (he = gethostbyname( hostname ) ) == NULL) {
herror("gethostbyname");
return 1;
}

addr_list = (struct in_addr **) he->h_addr_list;

for(i = 0; addr_list[i] != NULL; i++) {
//Return the first one;
strcpy(ip , inet_ntoa(*addr_list[i]) );
return 0;
}

return 1;
}

unsigned long long freespace(char *path) {
struct statvfs fData;

if(statvfs(path,&fData) != 0) {
printf("Failed to get free disk space on %s\n", path);
return 0;
}
return (unsigned long long)fData.f_bsize * fData.f_bfree;
}

// Free memory. Taken from http://stackoverflow.com/questions/2513505/how-to-get-available-memory-c-g
unsigned long long freemem() {
#ifdef _WIN32
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
GlobalMemoryStatusEx(&status);
return status.ullTotalPhys;
#else
long pages = sysconf(_SC_PHYS_PAGES);
long page_size = sysconf(_SC_PAGE_SIZE);
return (unsigned long long)pages * page_size;
#endif
}

7 changes: 7 additions & 0 deletions helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
int xstr2strr(char *buf, unsigned bufsize, const char *in);
int getNumberOfCores();
int hostname_to_ip(char * hostname , char* ip);
unsigned long long freespace(char *path);
unsigned long long freemem();


Loading

0 comments on commit b7043b9

Please sign in to comment.