Check-in [f87706a75e]
Overview
Comment:Start of work on OpenMP GPU offloading for work generation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f87706a75e4f085fb46d597d810a73a6a40a43a161ef2ca5076f7f604f375f75
User & Date: rkeene on 2018-08-17 20:37:44
Other Links: manifest | tags
Context
2018-08-17
20:39
More work on the networking support check-in: e79f2e1800 user: rkeene tags: trunk
20:37
Start of work on OpenMP GPU offloading for work generation check-in: f87706a75e user: rkeene tags: trunk
19:13
Run the same number of concurrent jobs as CPUs check-in: cc3e0b7bd2 user: rkeene tags: trunk
Changes

Modified configure.ac from [fe9fed8b62] to [d44ea11c0b].

58
59
60
61
62
63
64
























65
66
67
68
69
70
71
	AX_CHECK_COMPILE_FLAG([-Wno-tautological-constant-out-of-range-compare], [CFLAGS="$CFLAGS -Wno-tautological-constant-out-of-range-compare"])
])

dnl Enable hardening
AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [CFLAGS="$CFLAGS -fstack-protector-all"])
AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CFLAGS="$CFLAGS -fno-strict-overflow"])
AC_DEFINE([_FORTIFY_SOURCE], [2], [Enable fortification])

























dnl Random number generation mechanisms
AC_CHECK_FUNC(getrandom,, [
	AC_CHECK_FUNC(getentropy,, [
		AC_CHECK_FUNC(CryptGenRandom)
	])
])







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
	AX_CHECK_COMPILE_FLAG([-Wno-tautological-constant-out-of-range-compare], [CFLAGS="$CFLAGS -Wno-tautological-constant-out-of-range-compare"])
])

dnl Enable hardening
AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [CFLAGS="$CFLAGS -fstack-protector-all"])
AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CFLAGS="$CFLAGS -fno-strict-overflow"])
AC_DEFINE([_FORTIFY_SOURCE], [2], [Enable fortification])

dnl Enable OpenMP, if available
tcl_nano_openmp=''
AX_CHECK_COMPILE_FLAG([-fopenmp], [
	tcl_nano_openmp='-fopenmp'
], [
	AX_CHECK_COMPILE_FLAG([-xopenmp], [
		tcl_nano_openmp='-xopenmp'
	], [
		AX_CHECK_COMPILE_FLAG([-openmp], [
			tcl_nano_openmp='-openmp'
		], [
			AX_CHECK_COMPILE_FLAG([/openmp], [
				tcl_nano_openmp='/openmp'
			])
		])
	])
])

if test -n "${tcl_nano_openmp}"; then
	CFLAGS="$CFLAGS ${tcl_nano_openmp}"

	AC_DEFINE([NANO_TCL_HAVE_OPENMP], [1], [Define if you have support for OpenMP])
fi

dnl Random number generation mechanisms
AC_CHECK_FUNC(getrandom,, [
	AC_CHECK_FUNC(getentropy,, [
		AC_CHECK_FUNC(CryptGenRandom)
	])
])

Modified nano.c from [ac5d19ee67] to [11b3eba419].

1
2
3
4
5
6



7
8
9
10
11
12
13
#include <stdint.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <tcl.h>




#include "randombytes.h"
#include "tweetnacl.h"
#include "blake2.h"

#define NANO_SECRET_KEY_LENGTH (crypto_sign_SECRETKEYBYTES - crypto_sign_PUBLICKEYBYTES)
#define NANO_PUBLIC_KEY_LENGTH (crypto_sign_PUBLICKEYBYTES)






>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdint.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <tcl.h>
#ifdef NANO_TCL_HAVE_OPENMP
#  include <omp.h>
#endif

#include "randombytes.h"
#include "tweetnacl.h"
#include "blake2.h"

#define NANO_SECRET_KEY_LENGTH (crypto_sign_SECRETKEYBYTES - crypto_sign_PUBLICKEYBYTES)
#define NANO_PUBLIC_KEY_LENGTH (crypto_sign_PUBLICKEYBYTES)
412
413
414
415
416
417
418

419
420
421
422
423
424
425
static void nano_generate_work(const unsigned char *blockhash, unsigned char *workOut, uint64_t workMin) {
	unsigned char work[NANO_WORK_VALUE_LENGTH];
	unsigned int offset;
	int work_valid;

	memcpy(work, blockhash, sizeof(work));


	while (1) {
		work_valid = nano_validate_work(blockhash, work, workMin);
		if (work_valid) {
			break;
		}

		offset = 0;







>







415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
static void nano_generate_work(const unsigned char *blockhash, unsigned char *workOut, uint64_t workMin) {
	unsigned char work[NANO_WORK_VALUE_LENGTH];
	unsigned int offset;
	int work_valid;

	memcpy(work, blockhash, sizeof(work));

	#pragma omp target
	while (1) {
		work_valid = nano_validate_work(blockhash, work, workMin);
		if (work_valid) {
			break;
		}

		offset = 0;