update makefile to include all builds
This commit is contained in:
parent
d307619833
commit
a1d8d8d11a
|
|
@ -60,3 +60,8 @@ CMakeUserPresets.json
|
|||
*.ptx
|
||||
*.cubin
|
||||
*.fatbin
|
||||
|
||||
# Coin miner executables
|
||||
coin_miner_cpu
|
||||
coin_miner_simd
|
||||
coin_miner_cuda
|
||||
|
|
|
|||
|
|
@ -30,39 +30,61 @@ static int is_valid_coin(u32_t *hash)
|
|||
return hash[0] == 0xAAD20250u;
|
||||
}
|
||||
|
||||
//
|
||||
// increment coin variable part using the same logic as CPU miner
|
||||
// returns 0 if overflow (all positions wrapped around), 1 otherwise
|
||||
//
|
||||
static int increment_coin(u32_t coin[14])
|
||||
{
|
||||
// Increment the variable part using byte-by-byte logic with carry
|
||||
// Increment from the end to beginning (positions 53 down to 12)
|
||||
int pos = 53;
|
||||
while(pos >= 12)
|
||||
{
|
||||
u08_t *byte = &((u08_t *)coin)[pos ^ 3];
|
||||
if(*byte == '\n' || *byte == 0x80)
|
||||
*byte = 32; // Start from space
|
||||
|
||||
(*byte)++;
|
||||
|
||||
// Skip newline character
|
||||
if(*byte == '\n')
|
||||
(*byte)++;
|
||||
|
||||
// Wrap around at 127 (printable ASCII limit)
|
||||
if(*byte >= 127)
|
||||
{
|
||||
*byte = 32; // Reset to space
|
||||
pos--; // Carry to next position
|
||||
}
|
||||
else
|
||||
{
|
||||
break; // No carry needed
|
||||
}
|
||||
}
|
||||
|
||||
// Return 0 if we carried all the way through (overflow), 1 otherwise
|
||||
return (pos >= 12);
|
||||
}
|
||||
|
||||
//
|
||||
// prepare interleaved data for SIMD processing
|
||||
//
|
||||
static void prepare_coins(u32_t base_coin[14], u32_t *interleaved_data, int simd_width, u64_t base_counter)
|
||||
static void prepare_coins(u32_t base_coin[14], u32_t *interleaved_data, int simd_width)
|
||||
{
|
||||
for(int lane = 0; lane < simd_width; lane++)
|
||||
{
|
||||
u32_t coin[14];
|
||||
memcpy(coin, base_coin, sizeof(coin));
|
||||
|
||||
// Modify the coin for this lane (encode counter in the variable part)
|
||||
u64_t counter = base_counter + lane;
|
||||
for(int i = 12; i < 20 && i < 54; i++)
|
||||
{
|
||||
int shift = (19 - i) * 8;
|
||||
if(shift >= 0 && shift < 64)
|
||||
{
|
||||
u08_t byte = (counter >> shift) & 0xFF;
|
||||
// Map to ASCII printable range (32-126, excluding newline position)
|
||||
if(byte == '\n' || byte >= 0x80)
|
||||
byte = 'X';
|
||||
// Ensure byte is in printable ASCII range (32-126)
|
||||
// Map all values to ASCII printable characters: space (32) to tilde (126)
|
||||
// byte = 32 + (byte % 95);
|
||||
((u08_t *)coin)[i ^ 3] = byte;
|
||||
}
|
||||
}
|
||||
|
||||
// Interleave the data
|
||||
for(int idx = 0; idx < 14; idx++)
|
||||
{
|
||||
interleaved_data[idx * simd_width + lane] = coin[idx];
|
||||
}
|
||||
|
||||
// Increment the base coin for the next lane
|
||||
increment_coin(base_coin);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -125,19 +147,21 @@ static void mine_coins_avx(u64_t max_attempts)
|
|||
((u08_t *)base_coin)[0x36 ^ 3] = '\n';
|
||||
((u08_t *)base_coin)[0x37 ^ 3] = 0x80;
|
||||
|
||||
// Initialize variable part
|
||||
// Initialize variable part with A-Z cycling pattern (same as CPU miner)
|
||||
for(int i = 12; i < 54; i++)
|
||||
((u08_t *)base_coin)[i ^ 3] = 'A';
|
||||
((u08_t *)base_coin)[i ^ 3] = 'A' + (i - 12) % 26;
|
||||
|
||||
printf("Mining DETI coins using AVX (4-way SIMD)...\n");
|
||||
printf("Press Ctrl+C to stop\n\n");
|
||||
|
||||
time_measurement();
|
||||
time_measurement();
|
||||
double start_time = wall_time_delta();
|
||||
|
||||
while(keep_running && (max_attempts == 0 || attempts < max_attempts))
|
||||
{
|
||||
// Prepare coins for this batch
|
||||
prepare_coins(base_coin, interleaved_data, SIMD_WIDTH, attempts);
|
||||
prepare_coins(base_coin, interleaved_data, SIMD_WIDTH);
|
||||
|
||||
// Compute SHA1 hashes
|
||||
sha1_avx((v4si *)interleaved_data, (v4si *)interleaved_hash);
|
||||
|
|
@ -163,13 +187,16 @@ static void mine_coins_avx(u64_t max_attempts)
|
|||
// Print progress every 1M attempts
|
||||
if(attempts % 1000000 < SIMD_WIDTH)
|
||||
{
|
||||
printf("Attempts: %llu, Coins: %u\n",
|
||||
(unsigned long long)attempts, coins_found);
|
||||
time_measurement();
|
||||
double current_time = wall_time_delta() - start_time;
|
||||
double rate = attempts / current_time;
|
||||
printf("Attempts: %llu, Rate: %.2f MH/s, Coins: %u\n",
|
||||
(unsigned long long)attempts, rate / 1e6, coins_found);
|
||||
}
|
||||
}
|
||||
|
||||
time_measurement();
|
||||
double total_time = wall_time_delta();
|
||||
double total_time = wall_time_delta() - start_time;
|
||||
|
||||
printf("\n=== Mining Statistics ===\n");
|
||||
printf("Total attempts: %llu\n", (unsigned long long)attempts);
|
||||
|
|
@ -212,17 +239,20 @@ static void mine_coins_avx2(u64_t max_attempts)
|
|||
((u08_t *)base_coin)[0x36 ^ 3] = '\n';
|
||||
((u08_t *)base_coin)[0x37 ^ 3] = 0x80;
|
||||
|
||||
// Initialize variable part with A-Z cycling pattern (same as CPU miner)
|
||||
for(int i = 12; i < 54; i++)
|
||||
((u08_t *)base_coin)[i ^ 3] = 'A';
|
||||
((u08_t *)base_coin)[i ^ 3] = 'A' + (i - 12) % 26;
|
||||
|
||||
printf("Mining DETI coins using AVX2 (8-way SIMD)...\n");
|
||||
printf("Press Ctrl+C to stop\n\n");
|
||||
|
||||
time_measurement();
|
||||
time_measurement();
|
||||
double start_time = wall_time_delta();
|
||||
|
||||
while(keep_running && (max_attempts == 0 || attempts < max_attempts))
|
||||
{
|
||||
prepare_coins(base_coin, interleaved_data, SIMD_WIDTH, attempts);
|
||||
prepare_coins(base_coin, interleaved_data, SIMD_WIDTH);
|
||||
sha1_avx2((v8si *)interleaved_data, (v8si *)interleaved_hash);
|
||||
attempts += SIMD_WIDTH;
|
||||
|
||||
|
|
@ -244,13 +274,16 @@ static void mine_coins_avx2(u64_t max_attempts)
|
|||
|
||||
if(attempts % 1000000 < SIMD_WIDTH)
|
||||
{
|
||||
printf("Attempts: %llu, Coins: %u\n",
|
||||
(unsigned long long)attempts, coins_found);
|
||||
time_measurement();
|
||||
double current_time = wall_time_delta() - start_time;
|
||||
double rate = attempts / current_time;
|
||||
printf("Attempts: %llu, Rate: %.2f MH/s, Coins: %u\n",
|
||||
(unsigned long long)attempts, rate / 1e6, coins_found);
|
||||
}
|
||||
}
|
||||
|
||||
time_measurement();
|
||||
double total_time = wall_time_delta();
|
||||
double total_time = wall_time_delta() - start_time;
|
||||
|
||||
printf("\n=== Mining Statistics ===\n");
|
||||
printf("Total attempts: %llu\n", (unsigned long long)attempts);
|
||||
|
|
|
|||
30
makefile
30
makefile
|
|
@ -32,7 +32,7 @@ OPENCL_DIR = $(CUDA_DIR)
|
|||
# RTX 4070 -------------- sm_89
|
||||
#
|
||||
|
||||
CUDA_ARCH = sm_75
|
||||
CUDA_ARCH = sm_86
|
||||
|
||||
|
||||
#
|
||||
|
|
@ -42,6 +42,8 @@ CUDA_ARCH = sm_75
|
|||
clean:
|
||||
rm -f sha1_tests
|
||||
rm -f sha1_cuda_test sha1_cuda_kernel.cubin
|
||||
rm -f coin_miner_cpu coin_miner_simd coin_miner_cuda coin_miner_cuda_kernel.cubin
|
||||
rm -f benchmark
|
||||
rm -f a.out
|
||||
|
||||
|
||||
|
|
@ -64,3 +66,29 @@ sha1_cuda_kernel.cubin: aad_sha1_cuda_kernel.cu aad_sha1.h makefile
|
|||
nvcc -arch=$(CUDA_ARCH) --compiler-options -O2,-Wall -I$(CUDA_DIR)/include --cubin $< -o $@
|
||||
|
||||
all: sha1_tests sha1_cuda_test sha1_cuda_kernel.cubin
|
||||
|
||||
|
||||
#
|
||||
# DETI coin miners
|
||||
#
|
||||
|
||||
coin_miner_cpu: aad_coin_miner_cpu.c aad_sha1.h aad_sha1_cpu.h aad_data_types.h aad_utilities.h aad_vault.h makefile
|
||||
cc -march=native -Wall -Wshadow -Werror -O3 $< -o $@
|
||||
|
||||
coin_miner_simd: aad_coin_miner_simd.c aad_sha1.h aad_sha1_cpu.h aad_data_types.h aad_utilities.h aad_vault.h makefile
|
||||
cc -march=native -Wall -Wshadow -Werror -O3 $< -o $@
|
||||
|
||||
coin_miner_cuda_kernel.cubin: aad_coin_miner_cuda_kernel.cu aad_sha1.h makefile
|
||||
nvcc -arch=$(CUDA_ARCH) --compiler-options -O2,-Wall -I$(CUDA_DIR)/include --cubin $< -o $@
|
||||
|
||||
coin_miner_cuda: aad_coin_miner_cuda.c coin_miner_cuda_kernel.cubin aad_sha1.h aad_sha1_cpu.h aad_data_types.h aad_utilities.h aad_vault.h aad_cuda_utilities.h makefile
|
||||
cc -march=native -Wall -Wshadow -Werror -O3 -I$(CUDA_DIR)/include $< -o $@ -lcuda
|
||||
|
||||
benchmark: aad_benchmark.c aad_sha1.h aad_sha1_cpu.h aad_data_types.h aad_utilities.h makefile
|
||||
cc -march=native -Wall -Wshadow -Werror -O3 $< -o $@
|
||||
|
||||
miners: coin_miner_cpu coin_miner_simd coin_miner_cuda benchmark
|
||||
|
||||
all: sha1_tests sha1_cuda_test sha1_cuda_kernel.cubin \
|
||||
coin_miner_cpu coin_miner_simd coin_miner_cuda coin_miner_cuda_kernel.cubin \
|
||||
benchmark
|
||||
Binary file not shown.
BIN
sha1_tests
BIN
sha1_tests
Binary file not shown.
Loading…
Reference in New Issue