Skip to content

Commit

Permalink
various extern cleanup + api history uids and gpu SM
Browse files Browse the repository at this point in the history
uids could be useful to create graphes from history data

Note: please do a clean build after this commit (changes in miner.h)
  • Loading branch information
tpruvot committed Nov 26, 2014
1 parent cb3f893 commit 6ae2816
Show file tree
Hide file tree
Showing 22 changed files with 57 additions and 89 deletions.
3 changes: 0 additions & 3 deletions JHA/cuda_jha_compactionTest.cu
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ static uint32_t *h_numValid[8];

static uint32_t *d_partSum[2][8]; // für bis zu vier partielle Summen

// aus heavy.cu
extern cudaError_t MyStreamSynchronize(cudaStream_t stream, int situation, int thr_id);

// True/False tester
typedef uint32_t(*cuda_compactTestFunction_t)(uint32_t *inpHash);

Expand Down
3 changes: 0 additions & 3 deletions JHA/cuda_jha_keccak512.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

#include "cuda_helper.h"

// aus heavy.cu
extern cudaError_t MyStreamSynchronize(cudaStream_t stream, int situation, int thr_id);

__constant__ uint64_t c_State[25];
__constant__ uint32_t c_PaddedMessage[18];

Expand Down
21 changes: 9 additions & 12 deletions api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@ static int bye = 0;

extern char *opt_api_allow;
extern int opt_api_listen; /* port */
extern uint64_t global_hashrate;
extern uint32_t accepted_count;
extern uint32_t rejected_count;
extern int device_map[8];
extern char *device_name[8];
extern int num_cpus;
extern char driver_version[32];
extern struct stratum_ctx stratum;
Expand Down Expand Up @@ -203,7 +200,7 @@ static char *getsummary(char *params)
"ALGO=%s;GPUS=%d;KHS=%.2f;ACC=%d;REJ=%d;"
"ACCMN=%.3f;DIFF=%.6f;UPTIME=%.0f;TS=%u|",
PACKAGE_NAME, PACKAGE_VERSION, APIVERSION,
algo, num_processors, (double)global_hashrate / 1000.0,
algo, active_gpus, (double)global_hashrate / 1000.0,
accepted_count, rejected_count,
accps, global_diff, uptime, (uint32_t) ts);
return buffer;
Expand Down Expand Up @@ -277,10 +274,10 @@ static void gpuhwinfos(int gpu_id)

card = device_name[gpu_id];

snprintf(buf, sizeof(buf), "GPU=%d;BUS=%hd;CARD=%s;MEM=%lu;"
snprintf(buf, sizeof(buf), "GPU=%d;BUS=%hd;CARD=%s;SM=%u;MEM=%lu;"
"TEMP=%.1f;FAN=%d;FREQ=%d;MEMFREQ=%d;PST=%s;"
"VID=%hx;PID=%hx;NVML=%d;NVAPI=%d;SN=%s;BIOS=%s|",
gpu_id, cgpu->gpu_bus, card, cgpu->gpu_mem,
gpu_id, cgpu->gpu_bus, card, cgpu->gpu_arch, cgpu->gpu_mem,
cgpu->gpu_temp, cgpu->gpu_fan, cgpu->gpu_clock, cgpu->gpu_memclock,
pstate, cgpu->gpu_vid, cgpu->gpu_pid, cgpu->nvml_id, cgpu->nvapi_id,
cgpu->gpu_sn, cgpu->gpu_desc);
Expand All @@ -304,12 +301,12 @@ static void syshwinfos()
{
char buf[256];

float temp = cpu_temp(0);
uint32_t clock = cpu_clock(0);
int cputc = (int) cpu_temp(0);
uint32_t cpuclk = cpu_clock(0);

memset(buf, 0, sizeof(buf));
snprintf(buf, sizeof(buf), "OS=%s;NVDRIVER=%s;CPUS=%d;CPUTEMP=%.1f;CPUFREQ=%d|",
os_name(), driver_version, num_cpus, temp, clock);
snprintf(buf, sizeof(buf), "OS=%s;NVDRIVER=%s;CPUS=%d;CPUTEMP=%d;CPUFREQ=%d|",
os_name(), driver_version, num_cpus, cputc, cpuclk);
strcat(buffer, buf);
}

Expand Down Expand Up @@ -341,9 +338,9 @@ static char *gethistory(char *params)
for (int i = 0; i < records; i++) {
time_t ts = data[i].tm_stat;
p += sprintf(p, "GPU=%d;H=%u;KHS=%.2f;DIFF=%.6f;"
"COUNT=%u;FOUND=%u;TS=%u|",
"COUNT=%u;FOUND=%u;ID=%u;TS=%u|",
data[i].gpu_id, data[i].height, data[i].hashrate, data[i].difficulty,
data[i].hashcount, data[i].hashfound, (uint32_t)ts);
data[i].hashcount, data[i].hashfound, data[i].uid, (uint32_t)ts);
}
return buffer;
}
Expand Down
2 changes: 1 addition & 1 deletion blake32.cu
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ extern "C" int scanhash_blake256(int thr_id, uint32_t *pdata, const uint32_t *pt
}

if (!init[thr_id]) {
if (num_processors > 1)
if (active_gpus > 1)
cudaSetDevice(device_map[thr_id]);
CUDA_CALL_OR_RET_X(cudaMallocHost(&h_resNonce[thr_id], NBN * sizeof(uint32_t)), 0);
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonce[thr_id], NBN * sizeof(uint32_t)), 0);
Expand Down
38 changes: 22 additions & 16 deletions ccminer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ bool want_stratum = true;
bool have_stratum = false;
static bool submit_old = false;
bool use_syslog = false;
static char* opt_syslog_pfx = (char*) PACKAGE_NAME;
bool use_colors = true;
static bool opt_background = false;
bool opt_quiet = false;
Expand All @@ -208,10 +207,10 @@ static double opt_difficulty = 1; // CH
bool opt_trust_pool = false;
uint16_t opt_vote = 9999;
int num_cpus;
int num_processors;
int device_map[8] = {0,1,2,3,4,5,6,7}; // CB
char *device_name[8]; // CB
int device_sm[8];
int active_gpus;
char * device_name[8];
short device_map[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
long device_sm[8] = { 0 };
char *rpc_user = NULL;
static char *rpc_url;
static char *rpc_userpass;
Expand Down Expand Up @@ -241,8 +240,9 @@ int opt_statsavg = 30;
int opt_intensity = 0;
uint32_t opt_work_size = 0; /* default */
uint32_t opt_work_adds = 0;

char *opt_api_allow = (char*) "127.0.0.1"; /* 0.0.0.0 for all ips */
// strdup on char* to allow a common free() if used
static char* opt_syslog_pfx = strdup(PROGRAM_NAME);
char *opt_api_allow = strdup("127.0.0.1"); /* 0.0.0.0 for all ips */
int opt_api_listen = 4068; /* 0 to disable */

#ifdef HAVE_GETOPT_LONG
Expand Down Expand Up @@ -409,6 +409,8 @@ void proper_exit(int reason)
if (hnvml)
wrap_nvml_destroy(hnvml);
#endif
free(opt_syslog_pfx);
free(opt_api_allow);
exit(reason);
}

Expand Down Expand Up @@ -1671,6 +1673,7 @@ static void parse_arg(int key, char *arg)
if (p) {
/* ip:port */
if (p - arg > 0) {
free(opt_api_allow);
opt_api_allow = strdup(arg);
opt_api_allow[p - arg] = '\0';
}
Expand Down Expand Up @@ -1872,8 +1875,10 @@ static void parse_arg(int key, char *arg)
case 1008:
applog(LOG_INFO, "Now logging to syslog...");
use_syslog = true;
if (arg && strlen(arg))
if (arg && strlen(arg)) {
free(opt_syslog_pfx);
opt_syslog_pfx = strdup(arg);
}
break;
case 'd': // CB
{
Expand All @@ -1899,7 +1904,7 @@ static void parse_arg(int key, char *arg)
}
}
// set number of active gpus
num_processors = opt_n_threads;
active_gpus = opt_n_threads;
pch = strtok (NULL, ",");
}
}
Expand Down Expand Up @@ -2079,7 +2084,7 @@ int main(int argc, char *argv[])
num_cpus = 1;

// number of gpus
num_processors = cuda_num_devices();
active_gpus = cuda_num_devices();
cuda_devicenames();

/* parse command line */
Expand Down Expand Up @@ -2133,12 +2138,12 @@ int main(int argc, char *argv[])
SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE);
#endif

if (num_processors == 0) {
if (active_gpus == 0) {
applog(LOG_ERR, "No CUDA devices found! terminating.");
exit(1);
}
if (!opt_n_threads)
opt_n_threads = num_processors;
opt_n_threads = active_gpus;

#ifdef HAVE_SYSLOG_H
if (use_syslog)
Expand Down Expand Up @@ -2208,7 +2213,7 @@ int main(int argc, char *argv[])

#ifdef USE_WRAPNVML
#ifndef WIN32
/* nvml is currently not usable on Windows (even for x64) */
/* nvml is currently not the best choice on Windows (only in x64) */
hnvml = wrap_nvml_create();
if (hnvml)
applog(LOG_INFO, "NVML GPU monitoring enabled.");
Expand Down Expand Up @@ -2241,8 +2246,9 @@ int main(int argc, char *argv[])
thr = &thr_info[i];

thr->id = i;
thr->gpu.gpu_id = device_map[i];
thr->gpu.thr_id = i;
thr->gpu.gpu_id = (uint8_t) device_map[i];
thr->gpu.gpu_arch = (uint16_t) device_sm[device_map[i]];
thr->q = tq_new();
if (!thr->q)
return 1;
Expand All @@ -2253,9 +2259,9 @@ int main(int argc, char *argv[])
}
}

applog(LOG_INFO, "%d miner threads started, "
applog(LOG_INFO, "%d miner thread%s started, "
"using '%s' algorithm.",
opt_n_threads,
opt_n_threads, opt_n_threads > 1 ? "s":"",
algo_names[opt_algo]);

#ifdef WIN32
Expand Down
12 changes: 6 additions & 6 deletions ccminer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
<CInterleavedPTX>false</CInterleavedPTX>
<MaxRegCount>80</MaxRegCount>
<PtxAsOptionV>true</PtxAsOptionV>
<Keep>true</Keep>
<Keep>false</Keep>
<CodeGeneration>compute_30,sm_30;compute_50,sm_50</CodeGeneration>
<AdditionalOptions>--ptxas-options="-O2" %(AdditionalOptions)</AdditionalOptions>
<Defines>
Expand Down Expand Up @@ -215,7 +215,7 @@
<CInterleavedPTX>false</CInterleavedPTX>
<MaxRegCount>80</MaxRegCount>
<PtxAsOptionV>true</PtxAsOptionV>
<Keep>true</Keep>
<Keep>false</Keep>
<CodeGeneration>compute_50,sm_50</CodeGeneration>
<Include>
</Include>
Expand Down Expand Up @@ -366,7 +366,7 @@
<CudaCompile Include="heavy\heavy.cu">
</CudaCompile>
<CudaCompile Include="JHA\cuda_jha_compactionTest.cu">
<AdditionalOptions Condition="'$(Configuration)'=='Release'">-Xptxas "-abi=yes -O2" %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)'=='Release'">-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
</CudaCompile>
<CudaCompile Include="JHA\cuda_jha_keccak512.cu">
Expand All @@ -375,7 +375,7 @@
</CudaCompile>
<CudaCompile Include="blake32.cu">
<MaxRegCount>64</MaxRegCount>
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options="-O2 -dlcm=cg" %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options="-dlcm=cg" %(AdditionalOptions)</AdditionalOptions>
<FastMath>true</FastMath>
</CudaCompile>
<CudaCompile Include="keccak\cuda_keccak256.cu">
Expand All @@ -384,7 +384,7 @@
<CudaCompile Include="keccak\keccak256.cu" />
<CudaCompile Include="pentablake.cu">
<MaxRegCount>80</MaxRegCount>
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options="-O2 -dlcm=cg" %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options="-dlcm=cg" %(AdditionalOptions)</AdditionalOptions>
<FastMath>true</FastMath>
</CudaCompile>
<CudaCompile Include="quark\animecoin.cu">
Expand All @@ -402,7 +402,7 @@
<CInterleavedPTX>false</CInterleavedPTX>
</CudaCompile>
<CudaCompile Include="quark\cuda_quark_compactionTest.cu">
<AdditionalOptions Condition="'$(Configuration)'=='Release'">-Xptxas "-abi=yes -O2" %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)'=='Release'">-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
</CudaCompile>
<CudaCompile Include="quark\cuda_quark_groestl512.cu">
Expand Down
6 changes: 1 addition & 5 deletions cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
#include "compat.h" // sleep
#endif

extern char *device_name[8];
extern int device_map[8];
extern int device_sm[8];

// CUDA Devices on the System
int cuda_num_devices()
{
Expand Down Expand Up @@ -74,7 +70,7 @@ void cuda_devicenames()
cudaGetDeviceProperties(&props, device_map[i]);

device_name[i] = strdup(props.name);
device_sm[i] = props.major * 100 + props.minor * 10;
device_sm[i] = (props.major * 100 + props.minor * 10);
}
}

Expand Down
4 changes: 2 additions & 2 deletions cuda_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

#include <stdint.h>

extern int device_map[8];
extern int device_sm[8];
extern "C" short device_map[8];
extern "C" long device_sm[8];

// common functions
extern void cuda_check_cpu_init(int thr_id, int threads);
Expand Down
3 changes: 0 additions & 3 deletions fuguecoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ extern "C" void my_fugue256(void *cc, const void *data, size_t len);
extern "C" void my_fugue256_close(void *cc, void *dst);
extern "C" void my_fugue256_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst);

extern int device_map[8];
extern int device_sm[8];

// vorbereitete Kontexte nach den ersten 80 Bytes
sph_fugue256_context ctx_fugue_const[8];

Expand Down
8 changes: 7 additions & 1 deletion miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ struct cgpu_info {
uint8_t has_monitoring;
float gpu_temp;
int gpu_fan;
uint16_t gpu_arch;
int gpu_clock;
int gpu_memclock;
size_t gpu_mem;
Expand All @@ -410,6 +411,7 @@ struct thr_api {
};

struct stats_data {
uint32_t uid;
uint32_t tm_stat;
uint32_t hashcount;
uint32_t height;
Expand Down Expand Up @@ -454,7 +456,7 @@ extern bool opt_protocol;
extern bool opt_tracegpu;
extern int opt_intensity;
extern int opt_n_threads;
extern int num_processors;
extern int active_gpus;
extern int opt_timeout;
extern bool want_longpoll;
extern bool have_longpoll;
Expand All @@ -478,6 +480,10 @@ extern uint32_t opt_work_size;
extern uint64_t global_hashrate;
extern double global_diff;

extern char* device_name[8];
extern short device_map[8];
extern long device_sm[8];

#define CL_N "\x1B[0m"
#define CL_RED "\x1B[31m"
#define CL_GRN "\x1B[32m"
Expand Down
2 changes: 1 addition & 1 deletion pentablake.cu
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ extern "C" int scanhash_pentablake(int thr_id, uint32_t *pdata, const uint32_t *
((uint32_t*)ptarget)[7] = 0x000F;

if (!init[thr_id]) {
if (num_processors > 1) {
if (active_gpus > 1) {
cudaSetDevice(device_map[thr_id]);
}
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], 64 * throughput));
Expand Down
3 changes: 0 additions & 3 deletions quark/cuda_bmw512.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

#include "cuda_helper.h"

// aus heavy.cu
extern cudaError_t MyStreamSynchronize(cudaStream_t stream, int situation, int thr_id);

// die Message it Padding zur Berechnung auf der GPU
__constant__ uint64_t c_PaddedMessage80[16]; // padded message (80 bytes + padding)

Expand Down
3 changes: 0 additions & 3 deletions quark/cuda_jh512.cu
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include "cuda_helper.h"

// aus heavy.cu
extern cudaError_t MyStreamSynchronize(cudaStream_t stream, int situation, int thr_id);

typedef struct {
uint32_t x[8][4]; /*the 1024-bit state, ( x[i][0] || x[i][1] || x[i][2] || x[i][3] ) is the ith row of the state in the pseudocode*/
uint32_t buffer[16]; /*the 512-bit message block to be hashed;*/
Expand Down
Loading

0 comments on commit 6ae2816

Please sign in to comment.