Skip to content

Commit

Permalink
Add AVX2-enabled functions for x86-64
Browse files Browse the repository at this point in the history
  • Loading branch information
pooler committed Jul 5, 2013
1 parent 44d4815 commit e878267
Show file tree
Hide file tree
Showing 8 changed files with 1,995 additions and 78 deletions.
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ Architecture-specific notes:
To use NEON instructions, add "-mfpu=neon" to CFLAGS.
x86: The miner checks for SSE2 instructions support at runtime,
and uses them if they are available.
x86-64: The miner can take advantage of AVX and XOP instructions,
x86-64: The miner can take advantage of AVX, AVX2 and XOP instructions,
but only if both the CPU and the operating system support them.
* Linux supports AVX starting from kernel version 2.6.30.
* FreeBSD supports AVX starting with 9.1-RELEASE.
* Mac OS X added AVX support in the 10.6.8 update.
* Windows supports AVX starting from Windows 7 SP1 and
Windows Server 2008 R2 SP1.
The configure script outputs a warning if the assembler
cannot compile AVX or XOP instructions. In that case, the miner
doesn't support some instruction sets. In that case, the miner
can still be built, but unavailable optimizations are left off.

Usage instructions: Run "minerd --help" to see options.
Expand Down
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ then
AC_MSG_RESULT(no)
AC_MSG_WARN([The assembler does not support the XOP instruction set.])
)
AC_MSG_CHECKING(whether we can compile AVX2 code)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[asm ("vpaddd %ymm0, %ymm1, %ymm2");])],
AC_DEFINE(USE_AVX2, 1, [Define to 1 if AVX2 assembly is available.])
AC_MSG_RESULT(yes)
,
AC_MSG_RESULT(no)
AC_MSG_WARN([The assembler does not support the AVX2 instruction set.])
)
,
AC_MSG_RESULT(no)
AC_MSG_WARN([The assembler does not support the AVX instruction set.])
Expand Down
2 changes: 1 addition & 1 deletion cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ static void *miner_thread(void *userdata)
int thr_id = mythr->id;
struct work work;
uint32_t max_nonce;
uint32_t end_nonce = 0xffffffffU / opt_n_threads * (thr_id + 1) - 0x10;
uint32_t end_nonce = 0xffffffffU / opt_n_threads * (thr_id + 1) - 0x20;
unsigned char *scratchbuf = NULL;
char s[16];
int i;
Expand Down
7 changes: 7 additions & 0 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ void sha256_init_4way(uint32_t *state);
void sha256_transform_4way(uint32_t *state, const uint32_t *block, int swap);
#endif

#if defined(__x86_64__) && defined(USE_AVX2)
#define HAVE_SHA256_8WAY 1
int sha256_use_8way();
void sha256_init_8way(uint32_t *state);
void sha256_transform_8way(uint32_t *state, const uint32_t *block, int swap);
#endif

extern int scanhash_sha256d(int thr_id, uint32_t *pdata,
const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done);

Expand Down
Loading

0 comments on commit e878267

Please sign in to comment.