mirror of
https://github.com/GOSTSec/gostoclminer
synced 2025-01-30 16:34:29 +00:00
detect number of GPUs, start thread for every GPU
This commit is contained in:
parent
b6bf5a2ec7
commit
50f08a3e5e
19
miner.c
19
miner.c
@ -48,6 +48,7 @@ static int opt_n_threads = 1;
|
|||||||
static char *rpc_url = DEF_RPC_URL;
|
static char *rpc_url = DEF_RPC_URL;
|
||||||
static char *userpass = DEF_RPC_USERPASS;
|
static char *userpass = DEF_RPC_USERPASS;
|
||||||
|
|
||||||
|
_clState *clStates[16];
|
||||||
|
|
||||||
struct option_help {
|
struct option_help {
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -251,14 +252,8 @@ static void *miner_thread(void *thr_id_int)
|
|||||||
|
|
||||||
cl_int status;
|
cl_int status;
|
||||||
|
|
||||||
_clState *clState;
|
_clState *clState = clStates[thr_id];
|
||||||
|
|
||||||
char name[32];
|
|
||||||
|
|
||||||
printf("Init GPU %i\n", thr_id);
|
|
||||||
clState = initCl(thr_id, name, sizeof(name));
|
|
||||||
printf("initCl() finished. Found %s\n", name);
|
|
||||||
|
|
||||||
status = clSetKernelArg(clState->kernel, 0, sizeof(cl_mem), (void *)&clState->inputBuffer);
|
status = clSetKernelArg(clState->kernel, 0, sizeof(cl_mem), (void *)&clState->inputBuffer);
|
||||||
if(status != CL_SUCCESS) { printf("Error: Setting kernel argument 1.\n"); return false; }
|
if(status != CL_SUCCESS) { printf("Error: Setting kernel argument 1.\n"); return false; }
|
||||||
|
|
||||||
@ -318,8 +313,6 @@ static void *miner_thread(void *thr_id_int)
|
|||||||
globalThreads[0] = threads;
|
globalThreads[0] = threads;
|
||||||
localThreads[0] = 128;
|
localThreads[0] = 128;
|
||||||
|
|
||||||
printf("%i\n", work[frame].blk.nonce);
|
|
||||||
|
|
||||||
status = clEnqueueWriteBuffer(clState->commandQueue, clState->inputBuffer, CL_TRUE, 0,
|
status = clEnqueueWriteBuffer(clState->commandQueue, clState->inputBuffer, CL_TRUE, 0,
|
||||||
sizeof(dev_blk_ctx), (void *)&work[frame].blk, 0, NULL, NULL);
|
sizeof(dev_blk_ctx), (void *)&work[frame].blk, 0, NULL, NULL);
|
||||||
if(status != CL_SUCCESS) { printf("Error: clEnqueueWriteBuffer failed.\n"); return 0; }
|
if(status != CL_SUCCESS) { printf("Error: clEnqueueWriteBuffer failed.\n"); return 0; }
|
||||||
@ -480,10 +473,16 @@ int main (int argc, char *argv[])
|
|||||||
return nDevs;
|
return nDevs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char name[32];
|
||||||
|
|
||||||
/* start mining threads */
|
/* start mining threads */
|
||||||
for (i = 0; i < opt_n_threads; i++) {
|
for (i = 0; i < nDevs; i++) {
|
||||||
pthread_t t;
|
pthread_t t;
|
||||||
|
|
||||||
|
printf("Init GPU %i\n", i);
|
||||||
|
clStates[i] = initCl(i, name, sizeof(name));
|
||||||
|
printf("initCl() finished. Found %s\n", name);
|
||||||
|
|
||||||
if (pthread_create(&t, NULL, miner_thread,
|
if (pthread_create(&t, NULL, miner_thread,
|
||||||
(void *)(unsigned long) i)) {
|
(void *)(unsigned long) i)) {
|
||||||
fprintf(stderr, "thread %d create failed\n", i);
|
fprintf(stderr, "thread %d create failed\n", i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user