Browse Source

move CPU chipset specific optimization into device-cpu

nfactor-troky
zefir 13 years ago
parent
commit
713e8be629
  1. 1
      api.c
  2. 3
      cgminer.c
  3. 54
      device-cpu.c
  4. 41
      device-cpu.h
  5. 8
      device-gpu.c
  6. 1
      device-gpu.h
  7. 2
      findnonce.c
  8. 90
      miner.h
  9. 1
      ocl.h
  10. 3
      sha256_4way.c
  11. 3
      sha256_altivec_4way.c
  12. 4
      sha256_sse2_amd64.c
  13. 4
      sha256_sse2_i386.c
  14. 4
      sha256_sse4_amd64.c
  15. 2
      sha256_via.c

1
api.c

@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
#include "compat.h"
#include "miner.h"
#include "device-cpu.h" /* for algo_names[], TODO: re-factor dependency */
#if defined(unix) || defined(__APPLE__)
#include <errno.h>

3
cgminer.c

@ -42,9 +42,6 @@ @@ -42,9 +42,6 @@
#include "compat.h"
#include "miner.h"
#include "findnonce.h"
#include "bench_block.h"
#include "ocl.h"
#include "uthash.h"
#include "adl.h"
#include "device-cpu.h"
#include "device-gpu.h"

54
device-cpu.c

@ -81,6 +81,60 @@ extern char *set_int_range(const char *arg, int *i, int min, int max); @@ -81,6 +81,60 @@ extern char *set_int_range(const char *arg, int *i, int min, int max);
extern int dev_from_id(int thr_id);
/* chipset-optimized hash functions */
extern bool ScanHash_4WaySSE2(int, const unsigned char *pmidstate,
unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
extern bool ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
extern bool scanhash_via(int, const unsigned char *pmidstate,
unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *target,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
extern bool scanhash_c(int, const unsigned char *midstate, unsigned char *data,
unsigned char *hash1, unsigned char *hash,
const unsigned char *target,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
extern bool scanhash_cryptopp(int, const unsigned char *midstate,unsigned char *data,
unsigned char *hash1, unsigned char *hash,
const unsigned char *target,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
extern bool scanhash_asm32(int, const unsigned char *midstate,unsigned char *data,
unsigned char *hash1, unsigned char *hash,
const unsigned char *target,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
extern bool scanhash_sse2_64(int, const unsigned char *pmidstate, unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce);
extern bool scanhash_sse4_64(int, const unsigned char *pmidstate, unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce);
extern bool scanhash_sse2_32(int, const unsigned char *pmidstate, unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce);
#ifdef WANT_CPUMINE
static size_t max_name_len = 0;
static char *name_spaces_pad = NULL;

41
device-cpu.h

@ -1,12 +1,51 @@ @@ -1,12 +1,51 @@
#ifndef __DEVICE_CPU_H__
#define __DEVICE_CPU_H__
#include "miner.h"
#include "miner.h" /* for work_restart, TODO: re-factor dependency */
#include "config.h"
#include <stdbool.h>
#ifndef OPT_SHOW_LEN
#define OPT_SHOW_LEN 80
#endif
#ifdef __SSE2__
#define WANT_SSE2_4WAY 1
#endif
#ifdef __ALTIVEC__
#define WANT_ALTIVEC_4WAY 1
#endif
#if defined(__i386__) && defined(HAS_YASM) && defined(__SSE2__)
#define WANT_X8632_SSE2 1
#endif
#if (defined(__i386__) || defined(__x86_64__)) && !defined(__APPLE__)
#define WANT_VIA_PADLOCK 1
#endif
#if defined(__x86_64__) && defined(HAS_YASM)
#define WANT_X8664_SSE2 1
#endif
#if defined(__x86_64__) && defined(HAS_YASM)
#define WANT_X8664_SSE4 1
#endif
enum sha256_algos {
ALGO_C, /* plain C */
ALGO_4WAY, /* parallel SSE2 */
ALGO_VIA, /* VIA padlock */
ALGO_CRYPTOPP, /* Crypto++ (C) */
ALGO_CRYPTOPP_ASM32, /* Crypto++ 32-bit assembly */
ALGO_SSE2_32, /* SSE2 for x86_32 */
ALGO_SSE2_64, /* SSE2 for x86_64 */
ALGO_SSE4_64, /* SSE4 for x86_64 */
ALGO_ALTIVEC_4WAY, /* parallel Altivec */
};
extern const char *algo_names[];
extern bool opt_usecpu;
extern struct device_api cpu_api;

8
device-gpu.c

@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
#include "compat.h"
#include "miner.h"
#include "device-cpu.h"
#include "device-gpu.h"
#include "findnonce.h"
#include "ocl.h"
#include "adl.h"
@ -58,6 +58,12 @@ extern void decay_time(double *f, double fadd); @@ -58,6 +58,12 @@ extern void decay_time(double *f, double fadd);
/**********************************************/
#ifdef HAVE_ADL
extern float gpu_temp(int gpu);
extern int gpu_fanspeed(int gpu);
extern int gpu_fanpercent(int gpu);
#endif
#ifdef HAVE_OPENCL
char *set_vector(const char *arg, int *i)

1
device-gpu.h

@ -20,6 +20,7 @@ void manage_gpu(void); @@ -20,6 +20,7 @@ void manage_gpu(void);
extern void pause_dynamic_threads(int gpu);
extern bool have_opencl;
extern int opt_platform_id;
extern struct device_api opencl_api;

2
findnonce.c

@ -16,9 +16,7 @@ @@ -16,9 +16,7 @@
#include <pthread.h>
#include <string.h>
#include "ocl.h"
#include "findnonce.h"
#include "miner.h"
const uint32_t SHA256_K[64] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,

90
miner.h

@ -60,30 +60,6 @@ void *alloca (size_t); @@ -60,30 +60,6 @@ void *alloca (size_t);
#include "ADL_SDK/adl_sdk.h"
#endif
#ifdef __SSE2__
#define WANT_SSE2_4WAY 1
#endif
#ifdef __ALTIVEC__
#define WANT_ALTIVEC_4WAY 1
#endif
#if defined(__i386__) && defined(HAS_YASM) && defined(__SSE2__)
#define WANT_X8632_SSE2 1
#endif
#if (defined(__i386__) || defined(__x86_64__)) && !defined(__APPLE__)
#define WANT_VIA_PADLOCK 1
#endif
#if defined(__x86_64__) && defined(HAS_YASM)
#define WANT_X8664_SSE2 1
#endif
#if defined(__x86_64__) && defined(HAS_YASM)
#define WANT_X8664_SSE4 1
#endif
#if !defined(WIN32) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
#define bswap_16 __builtin_bswap16
#define bswap_32 __builtin_bswap32
@ -157,19 +133,6 @@ enum { @@ -157,19 +133,6 @@ enum {
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
enum sha256_algos {
ALGO_C, /* plain C */
ALGO_4WAY, /* parallel SSE2 */
ALGO_VIA, /* VIA padlock */
ALGO_CRYPTOPP, /* Crypto++ (C) */
ALGO_CRYPTOPP_ASM32, /* Crypto++ 32-bit assembly */
ALGO_SSE2_32, /* SSE2 for x86_32 */
ALGO_SSE2_64, /* SSE2 for x86_64 */
ALGO_SSE4_64, /* SSE4 for x86_64 */
ALGO_ALTIVEC_4WAY, /* parallel Altivec */
};
enum alive {
LIFE_WELL,
LIFE_SICK,
@ -473,56 +436,6 @@ typedef bool (*sha256_func)(int thr_id, const unsigned char *pmidstate, @@ -473,56 +436,6 @@ typedef bool (*sha256_func)(int thr_id, const unsigned char *pmidstate,
uint32_t *last_nonce,
uint32_t nonce);
extern bool ScanHash_4WaySSE2(int, const unsigned char *pmidstate,
unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
extern bool ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
extern bool scanhash_via(int, const unsigned char *pmidstate,
unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *target,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
extern bool scanhash_c(int, const unsigned char *midstate, unsigned char *data,
unsigned char *hash1, unsigned char *hash,
const unsigned char *target,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
extern bool scanhash_cryptopp(int, const unsigned char *midstate,unsigned char *data,
unsigned char *hash1, unsigned char *hash,
const unsigned char *target,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
extern bool scanhash_asm32(int, const unsigned char *midstate,unsigned char *data,
unsigned char *hash1, unsigned char *hash,
const unsigned char *target,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
extern bool scanhash_sse2_64(int, const unsigned char *pmidstate, unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce);
extern bool scanhash_sse4_64(int, const unsigned char *pmidstate, unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce);
extern bool scanhash_sse2_32(int, const unsigned char *pmidstate, unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce);
extern int
timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
@ -542,9 +455,6 @@ extern void kill_work(void); @@ -542,9 +455,6 @@ extern void kill_work(void);
extern void reinit_device(struct cgpu_info *cgpu);
#ifdef HAVE_ADL
extern float gpu_temp(int gpu);
extern int gpu_fanspeed(int gpu);
extern int gpu_fanpercent(int gpu);
extern bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc, int *activity, int *fanspeed, int *fanpercent, int *powertune);
extern int set_fanspeed(int gpu, int iFanSpeed);
extern int set_vddc(int gpu, float fVddc);

1
ocl.h

@ -30,6 +30,5 @@ typedef struct { @@ -30,6 +30,5 @@ typedef struct {
extern char *file_contents(const char *filename, int *length);
extern int clDevicesNum(void);
extern _clState *initCl(unsigned int gpu, char *name, size_t nameSize);
extern int opt_platform_id;
#endif /* HAVE_OPENCL */
#endif /* __OCL_H__ */

3
sha256_4way.c

@ -4,8 +4,7 @@ @@ -4,8 +4,7 @@
// tcatm's 4-way 128-bit SSE2 SHA-256
#include "config.h"
#include "miner.h"
#include "device-cpu.h"
#ifdef WANT_SSE2_4WAY

3
sha256_altivec_4way.c

@ -9,8 +9,7 @@ @@ -9,8 +9,7 @@
//
//#include "config.h"
#include "miner.h"
#include "device-cpu.h"
#ifdef WANT_ALTIVEC_4WAY

4
sha256_sse2_amd64.c

@ -9,9 +9,7 @@ @@ -9,9 +9,7 @@
*
*/
#include "config.h"
#include "miner.h"
#include "device-cpu.h"
#ifdef WANT_X8664_SSE2

4
sha256_sse2_i386.c

@ -9,9 +9,7 @@ @@ -9,9 +9,7 @@
*
*/
#include "config.h"
#include "miner.h"
#include "device-cpu.h"
#ifdef WANT_X8632_SSE2

4
sha256_sse4_amd64.c

@ -9,9 +9,7 @@ @@ -9,9 +9,7 @@
*
*/
#include "config.h"
#include "miner.h"
#include "device-cpu.h"
#ifdef WANT_X8664_SSE4

2
sha256_via.c

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#include "config.h"
#include "device-cpu.h"
#include <stdint.h>
#include <stdlib.h>

Loading…
Cancel
Save