Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -60,10 +60,34 @@ 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) Index: nano.c ================================================================== --- nano.c +++ nano.c @@ -2,10 +2,13 @@ #include #include #include #include #include +#ifdef NANO_TCL_HAVE_OPENMP +# include +#endif #include "randombytes.h" #include "tweetnacl.h" #include "blake2.h" @@ -414,10 +417,11 @@ 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; }