Remove OpenCL scan
Signed-off-by: Tiago Garcia <tiago.rgarcia@ua.pt>
This commit is contained in:
parent
ecf0ac85cd
commit
0f2225f1d4
|
|
@ -43,7 +43,7 @@ static double get_wall_time(void)
|
|||
//
|
||||
// Mine DETI coins using OpenCL
|
||||
//
|
||||
static void mine_coins_ocl(u64_t max_attempts, int use_scan_kernel)
|
||||
static void mine_coins_ocl(u64_t max_attempts)
|
||||
{
|
||||
ocl_data_t od;
|
||||
u32_t *host_storage;
|
||||
|
|
@ -55,7 +55,7 @@ static void mine_coins_ocl(u64_t max_attempts, int use_scan_kernel)
|
|||
od.platform_number = 0;
|
||||
od.device_number = 0;
|
||||
od.kernel_file_name = "aad_coin_miner_ocl_kernel.cl";
|
||||
od.kernel_name = use_scan_kernel ? "mine_deti_coins_scan_kernel" : "mine_deti_coins_kernel";
|
||||
od.kernel_name = "mine_deti_coins_kernel";
|
||||
od.data_size[0] = COINS_STORAGE_SIZE * sizeof(u32_t);
|
||||
od.data_size[1] = 0;
|
||||
|
||||
|
|
@ -78,7 +78,6 @@ static void mine_coins_ocl(u64_t max_attempts, int use_scan_kernel)
|
|||
|
||||
u32_t param1 = (u32_t)time(NULL);
|
||||
u32_t param2 = 0x12345678u;
|
||||
int scan_pos = 12;
|
||||
|
||||
double start_time = get_wall_time();
|
||||
|
||||
|
|
@ -91,12 +90,10 @@ static void mine_coins_ocl(u64_t max_attempts, int use_scan_kernel)
|
|||
host_to_device_copy(&od, 0);
|
||||
|
||||
// Set kernel arguments
|
||||
od.n_kernel_arguments = use_scan_kernel ? 4 : 3;
|
||||
od.n_kernel_arguments = 3;
|
||||
set_kernel_arg(&od, 0, sizeof(cl_mem), &od.device_data[0]);
|
||||
set_kernel_arg(&od, 1, sizeof(u32_t), ¶m1);
|
||||
set_kernel_arg(&od, 2, sizeof(u32_t), ¶m2);
|
||||
if(use_scan_kernel)
|
||||
set_kernel_arg(&od, 3, sizeof(int), &scan_pos);
|
||||
|
||||
// Launch the OpenCL kernel
|
||||
launch_kernel(&od);
|
||||
|
|
@ -129,16 +126,11 @@ static void mine_coins_ocl(u64_t max_attempts, int use_scan_kernel)
|
|||
|
||||
// Update counters
|
||||
kernel_runs++;
|
||||
if(use_scan_kernel)
|
||||
attempts += n_threads * 95; // Each thread tries 95 printable ASCII values
|
||||
else
|
||||
attempts += n_threads;
|
||||
|
||||
// Update parameters for next iteration
|
||||
param1++;
|
||||
param2 = param2 ^ 0x9E3779B9u;
|
||||
if(use_scan_kernel)
|
||||
scan_pos = (scan_pos + 1) % 42 + 12;
|
||||
|
||||
// Print progress every 10 kernel launches
|
||||
if(kernel_runs % 10 == 0)
|
||||
|
|
@ -168,20 +160,13 @@ static void mine_coins_ocl(u64_t max_attempts, int use_scan_kernel)
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
u64_t max_attempts = 0;
|
||||
int use_scan_kernel = 0;
|
||||
|
||||
signal(SIGINT, signal_handler);
|
||||
|
||||
if(argc > 1)
|
||||
max_attempts = strtoull(argv[1], NULL, 10);
|
||||
|
||||
if(argc > 2 && strcmp(argv[2], "scan") == 0)
|
||||
{
|
||||
use_scan_kernel = 1;
|
||||
printf("Using scan kernel (tries 95 values per thread)\n");
|
||||
}
|
||||
|
||||
mine_coins_ocl(max_attempts, use_scan_kernel);
|
||||
mine_coins_ocl(max_attempts);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,77 +179,3 @@ __kernel void mine_deti_coins_kernel(__global uint *storage, uint param1, uint p
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Scan kernel - each work item tries 256 variations
|
||||
//
|
||||
__kernel void mine_deti_coins_scan_kernel(__global uint *storage, uint param1, uint param2, int scan_pos)
|
||||
{
|
||||
uint gid = get_global_id(0);
|
||||
uint coin[14];
|
||||
uint hash[5];
|
||||
|
||||
// Initialize coin
|
||||
for(int i = 0; i < 14; i++)
|
||||
coin[i] = 0;
|
||||
|
||||
__private uchar *bytes = (__private uchar *)coin;
|
||||
|
||||
// Fixed parts
|
||||
bytes[0x0 ^ 3] = 'D';
|
||||
bytes[0x1 ^ 3] = 'E';
|
||||
bytes[0x2 ^ 3] = 'T';
|
||||
bytes[0x3 ^ 3] = 'I';
|
||||
bytes[0x4 ^ 3] = ' ';
|
||||
bytes[0x5 ^ 3] = 'c';
|
||||
bytes[0x6 ^ 3] = 'o';
|
||||
bytes[0x7 ^ 3] = 'i';
|
||||
bytes[0x8 ^ 3] = 'n';
|
||||
bytes[0x9 ^ 3] = ' ';
|
||||
bytes[0xa ^ 3] = '2';
|
||||
bytes[0xb ^ 3] = ' ';
|
||||
bytes[0x36 ^ 3] = '\n';
|
||||
bytes[0x37 ^ 3] = 0x80;
|
||||
|
||||
// Generate base content unique to this thread
|
||||
uint seed = param1 + gid * 0x9E3779B9u;
|
||||
uint seed2 = param2 ^ (gid * 0x61C88647u);
|
||||
|
||||
for(int i = 12; i < 54; i++)
|
||||
{
|
||||
seed = seed * 1664525u + 1013904223u;
|
||||
seed2 ^= seed2 << 13;
|
||||
seed2 ^= seed2 >> 17;
|
||||
seed2 ^= seed2 << 5;
|
||||
|
||||
uchar val = 32 + ((seed ^ seed2) % 95);
|
||||
if(val == '\n') val = ' ';
|
||||
if(val >= 127) val = 126;
|
||||
|
||||
bytes[i ^ 3] = val;
|
||||
}
|
||||
|
||||
// Validate scan_pos
|
||||
if(scan_pos < 12 || scan_pos >= 54)
|
||||
scan_pos = 12;
|
||||
|
||||
// Scan through all printable ASCII values at scan_pos
|
||||
for(uint c = 32; c < 127; c++)
|
||||
{
|
||||
if(c == '\n') continue; // Skip newline
|
||||
|
||||
bytes[scan_pos ^ 3] = (uchar)c;
|
||||
|
||||
sha1_compute(coin, hash);
|
||||
|
||||
if(hash[0] == 0xAAD20250u)
|
||||
{
|
||||
uint idx = atomic_add(&storage[0], 14u);
|
||||
if(idx + 14 <= 1024)
|
||||
{
|
||||
for(int i = 0; i < 14; i++)
|
||||
storage[idx + i] = coin[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue