1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-22 12:34:27 +00:00

move CPU chipset specific optimization into device-cpu

This commit is contained in:
zefir 2012-02-04 14:22:47 +01:00
parent 52bb99c3ea
commit 713e8be629
15 changed files with 109 additions and 112 deletions

1
api.c
View File

@ -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>

View File

@ -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"

View File

@ -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;

View File

@ -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;

View File

@ -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);
/**********************************************/
#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)

View File

@ -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;

View File

@ -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
View File

@ -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 {
#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,
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);
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
View File

@ -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__ */

View File

@ -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

View File

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

View File

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

View File

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

View File

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

View File

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