mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Merge https://github.com/geekmug/cgminer into gitmug
This commit is contained in:
commit
28796de72e
42
main.c
42
main.c
@ -82,7 +82,7 @@ static inline void affine_to_cpu(int id, int cpu)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
enum workio_commands {
|
||||
WC_GET_WORK,
|
||||
WC_SUBMIT_WORK,
|
||||
@ -675,7 +675,7 @@ static double bench_algo_stage2(
|
||||
);
|
||||
|
||||
// Create and init a chunked of shared memory
|
||||
HANDLE map_handle = CreateFileMapping(
|
||||
HANDLE map_handle = CreateFileMapping(
|
||||
INVALID_HANDLE_VALUE, // use paging file
|
||||
NULL, // default security attributes
|
||||
PAGE_READWRITE, // read/write access
|
||||
@ -688,7 +688,7 @@ static double bench_algo_stage2(
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void *shared_mem = MapViewOfFile(
|
||||
void *shared_mem = MapViewOfFile(
|
||||
map_handle, // object to map view of
|
||||
FILE_MAP_WRITE, // read/write access
|
||||
0, // high offset: map from
|
||||
@ -731,7 +731,7 @@ static double bench_algo_stage2(
|
||||
FALSE, // Set handle inheritance to FALSE
|
||||
DEBUG_ONLY_THIS_PROCESS,// We're going to debug the child
|
||||
NULL, // Use parent's environment block
|
||||
NULL, // Use parent's starting directory
|
||||
NULL, // Use parent's starting directory
|
||||
&startup_info, // Pointer to STARTUPINFO structure
|
||||
&process_info // Pointer to PROCESS_INFORMATION structure
|
||||
);
|
||||
@ -787,8 +787,8 @@ static double bench_algo_stage2(
|
||||
|
||||
// Reap return value and cleanup
|
||||
CopyMemory(&rate, shared_mem, sizeof(rate));
|
||||
(void)UnmapViewOfFile(shared_mem);
|
||||
(void)CloseHandle(map_handle);
|
||||
(void)UnmapViewOfFile(shared_mem);
|
||||
(void)CloseHandle(map_handle);
|
||||
|
||||
#else
|
||||
|
||||
@ -2367,7 +2367,7 @@ static void disable_curses(void)
|
||||
HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
COORD coord;
|
||||
|
||||
|
||||
if (GetConsoleScreenBufferInfo(hout, &csbi)) {
|
||||
coord.X = 0;
|
||||
coord.Y = csbi.dwSize.Y - 1;
|
||||
@ -3487,7 +3487,6 @@ static void hashmeter(int thr_id, struct timeval *diff,
|
||||
static double local_mhashes_done = 0;
|
||||
static double rolling = 0;
|
||||
double local_mhashes = (double)hashes_done / 1000000.0;
|
||||
struct cgpu_info *cgpu = thr_info[thr_id].cgpu;
|
||||
bool showlog = false;
|
||||
|
||||
/* Update the last time this thread reported in */
|
||||
@ -3497,12 +3496,13 @@ static void hashmeter(int thr_id, struct timeval *diff,
|
||||
/* Don't bother calculating anything if we're not displaying it */
|
||||
if (opt_realquiet || !opt_log_interval)
|
||||
return;
|
||||
|
||||
|
||||
secs = (double)diff->tv_sec + ((double)diff->tv_usec / 1000000.0);
|
||||
|
||||
/* So we can call hashmeter from a non worker thread */
|
||||
if (thr_id >= 0) {
|
||||
struct thr_info *thr = &thr_info[thr_id];
|
||||
struct cgpu_info *cgpu = thr_info[thr_id].cgpu;
|
||||
double thread_rolling = 0.0;
|
||||
int i;
|
||||
|
||||
@ -4218,7 +4218,7 @@ static cl_int queue_phatk_kernel(_clState *clState, dev_blk_ctx *blk)
|
||||
status |= clSetKernelArg(*kernel, num++, sizeof(uint), (void *)&blk->ctx_f);
|
||||
status |= clSetKernelArg(*kernel, num++, sizeof(uint), (void *)&blk->ctx_g);
|
||||
status |= clSetKernelArg(*kernel, num++, sizeof(uint), (void *)&blk->ctx_h);
|
||||
|
||||
|
||||
status |= clSetKernelArg(*kernel, num++, sizeof(uint), (void *)&blk->cty_b);
|
||||
status |= clSetKernelArg(*kernel, num++, sizeof(uint), (void *)&blk->cty_c);
|
||||
status |= clSetKernelArg(*kernel, num++, sizeof(uint), (void *)&blk->cty_d);
|
||||
@ -4536,7 +4536,7 @@ static void *longpoll_thread(void *userdata)
|
||||
lp_url = hdr_path;
|
||||
hdr_path = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* absolute path, on current server */
|
||||
else {
|
||||
copy_start = (*hdr_path == '/') ? (hdr_path + 1) : hdr_path;
|
||||
@ -5259,6 +5259,8 @@ int main (int argc, char *argv[])
|
||||
init_max_name_len();
|
||||
|
||||
handler.sa_handler = &sighandler;
|
||||
handler.sa_flags = 0;
|
||||
sigemptyset(&handler.sa_mask);
|
||||
sigaction(SIGTERM, &handler, &termhandler);
|
||||
sigaction(SIGINT, &handler, &inthandler);
|
||||
|
||||
@ -5359,7 +5361,7 @@ int main (int argc, char *argv[])
|
||||
#if defined(WIN32)
|
||||
char unique_name[64];
|
||||
if (GetEnvironmentVariable("CGMINER_SHARED_MEM", unique_name, 32)) {
|
||||
HANDLE map_handle = CreateFileMapping(
|
||||
HANDLE map_handle = CreateFileMapping(
|
||||
INVALID_HANDLE_VALUE, // use paging file
|
||||
NULL, // default security attributes
|
||||
PAGE_READWRITE, // read/write access
|
||||
@ -5368,18 +5370,18 @@ int main (int argc, char *argv[])
|
||||
unique_name // name of map object
|
||||
);
|
||||
if (NULL!=map_handle) {
|
||||
void *shared_mem = MapViewOfFile(
|
||||
void *shared_mem = MapViewOfFile(
|
||||
map_handle, // object to map view of
|
||||
FILE_MAP_WRITE, // read/write access
|
||||
0, // high offset: map from
|
||||
0, // low offset: beginning
|
||||
0 // default: map entire file
|
||||
);
|
||||
if (NULL!=shared_mem)
|
||||
if (NULL!=shared_mem)
|
||||
CopyMemory(shared_mem, &rate, sizeof(rate));
|
||||
(void)UnmapViewOfFile(shared_mem);
|
||||
(void)UnmapViewOfFile(shared_mem);
|
||||
}
|
||||
(void)CloseHandle(map_handle);
|
||||
(void)CloseHandle(map_handle);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -5396,6 +5398,7 @@ int main (int argc, char *argv[])
|
||||
} else
|
||||
chosen_kernel = KL_NONE;
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
gpu_threads = nDevs * opt_g_threads;
|
||||
if (total_devices) {
|
||||
if (total_devices > nDevs)
|
||||
@ -5418,6 +5421,9 @@ int main (int argc, char *argv[])
|
||||
gpu_devices[i] = true;
|
||||
total_devices = nDevs;
|
||||
}
|
||||
#else
|
||||
gpu_threads = 0;
|
||||
#endif
|
||||
|
||||
if (!gpu_threads && !forced_n_threads) {
|
||||
/* Maybe they turned GPU off; restore default CPU threads. */
|
||||
@ -5456,7 +5462,7 @@ int main (int argc, char *argv[])
|
||||
quit(1, "Failed to malloc userpass");
|
||||
sprintf(pool->rpc_userpass, "%s:%s", pool->rpc_user, pool->rpc_pass);
|
||||
} else {
|
||||
pool->rpc_user = malloc(strlen(pool->rpc_userpass));
|
||||
pool->rpc_user = malloc(strlen(pool->rpc_userpass) + 1);
|
||||
if (!pool->rpc_user)
|
||||
quit(1, "Failed to malloc user");
|
||||
strcpy(pool->rpc_user, pool->rpc_userpass);
|
||||
@ -5498,7 +5504,7 @@ int main (int argc, char *argv[])
|
||||
quit(1, "Failed to tq_new");
|
||||
|
||||
/* start work I/O thread */
|
||||
if (thr_info_create(thr, NULL, workio_thread, thr))
|
||||
if (thr_info_create(thr, NULL, workio_thread, thr))
|
||||
quit(1, "workio thread create failed");
|
||||
|
||||
/* init longpoll thread info */
|
||||
|
10
miner.h
10
miner.h
@ -81,7 +81,9 @@ void *alloca (size_t);
|
||||
#endif
|
||||
|
||||
#if !defined(WIN32) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
||||
#define WANT_BUILTIN_BSWAP
|
||||
#define bswap_16 __builtin_bswap16
|
||||
#define bswap_32 __builtin_bswap32
|
||||
#define bswap_64 __builtin_bswap64
|
||||
#else
|
||||
#if HAVE_BYTESWAP_H
|
||||
#include <byteswap.h>
|
||||
@ -99,7 +101,7 @@ void *alloca (size_t);
|
||||
#define bswap_32(value) \
|
||||
(((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \
|
||||
(uint32_t)bswap_16((uint16_t)((value) >> 16)))
|
||||
|
||||
|
||||
#define bswap_64(value) \
|
||||
(((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \
|
||||
<< 32) | \
|
||||
@ -244,11 +246,7 @@ extern void thr_info_cancel(struct thr_info *thr);
|
||||
|
||||
static inline uint32_t swab32(uint32_t v)
|
||||
{
|
||||
#ifdef WANT_BUILTIN_BSWAP
|
||||
return __builtin_bswap32(v);
|
||||
#else
|
||||
return bswap_32(v);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void swap256(void *dest_p, const void *src_p)
|
||||
|
Loading…
Reference in New Issue
Block a user