rockm compile success

This commit is contained in:
Dobromir Popov
2025-09-06 11:41:40 +03:00
parent 856faefc1a
commit 27009b3d87
13 changed files with 49 additions and 25 deletions

View File

@@ -92,3 +92,4 @@ echo "Available algorithms:"\n\
# Default command # Default command
CMD ["sh", "-c", "echo 'Build completed successfully! Binaries available in /output/' && ls -la /output/"] CMD ["sh", "-c", "echo 'Build completed successfully! Binaries available in /output/' && ls -la /output/"]

View File

@@ -92,3 +92,4 @@ ls -la *.so\n\
# Default command # Default command
CMD ["sh", "-c", "echo 'ROCm GPU build completed successfully!' && ls -la /output/"] CMD ["sh", "-c", "echo 'ROCm GPU build completed successfully!' && ls -la /output/"]

View File

@@ -128,3 +128,4 @@ rinhash_cuda(input, input_len, output);\n\
# Default command # Default command
CMD ["sh", "-c", "echo 'ROCm GPU build completed successfully!' && ls -la /output/ && echo '' && echo 'Integration guide available in INTEGRATION.md'"] CMD ["sh", "-c", "echo 'ROCm GPU build completed successfully!' && ls -la /output/ && echo '' && echo 'Integration guide available in INTEGRATION.md'"]

View File

@@ -293,3 +293,4 @@ echo " 3. For GPU acceleration, install ROCm runtime and use the libraries"
echo "" echo ""
echo "RinHash ROCm GPU build system completed successfully!" echo "RinHash ROCm GPU build system completed successfully!"

View File

@@ -200,3 +200,4 @@ else
fi fi
echo "cpuminer build completed successfully!" echo "cpuminer build completed successfully!"

View File

@@ -223,3 +223,4 @@ else
fi fi
echo "cpuminer build completed successfully!" echo "cpuminer build completed successfully!"

View File

@@ -114,3 +114,4 @@ fi
echo "ROCm GPU build completed successfully!" echo "ROCm GPU build completed successfully!"

View File

@@ -111,3 +111,4 @@ fi
echo "ROCm GPU build completed successfully!" echo "ROCm GPU build completed successfully!"

View File

@@ -146,3 +146,4 @@ echo ""
echo "For more information about ROCm Docker containers, visit:" echo "For more information about ROCm Docker containers, visit:"
echo "https://github.com/ROCm/ROCm-docker" echo "https://github.com/ROCm/ROCm-docker"

View File

@@ -30,3 +30,4 @@ target_compile_options(rinhash-gpu-miner PRIVATE -O3 -march=native)
# Install target # Install target
install(TARGETS rinhash-gpu-miner DESTINATION bin) install(TARGETS rinhash-gpu-miner DESTINATION bin)

View File

@@ -1,5 +1,5 @@
#include <hip/hip_runtime.h> #include <cuda_runtime.h>
#include <hip/hip_runtime_api.h> #include <device_launch_parameters.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>

View File

@@ -7,13 +7,14 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <cstring> #include <cstring>
#include <cstdint> #include <cstdint>
#include <filesystem>
// HIP/ROCm runtime check (using dlopen, no direct headers needed) // HIP/ROCm runtime check (using dlopen, no direct headers needed)
// Forward declarations for GPU functions // Forward declarations for GPU functions
extern "C" { extern "C" {
void rinhash_cuda(const uint8_t* input, size_t input_len, uint8_t* output); void rinhash_hip(const uint8_t* input, size_t input_len, uint8_t* output);
void rinhash_cuda_batch(const uint8_t* block_headers, size_t block_header_len, void rinhash_hip_batch(const uint8_t* block_headers, size_t block_header_len,
uint8_t* outputs, uint32_t num_blocks); uint8_t* outputs, uint32_t num_blocks);
void RinHash(const uint32_t* version, const uint32_t* prev_block, void RinHash(const uint32_t* version, const uint32_t* prev_block,
const uint32_t* merkle_root, const uint32_t* timestamp, const uint32_t* merkle_root, const uint32_t* timestamp,
@@ -26,8 +27,8 @@ private:
bool gpu_available; bool gpu_available;
// Function pointers for GPU operations // Function pointers for GPU operations
decltype(&rinhash_cuda) gpu_rinhash; decltype(&rinhash_hip) gpu_rinhash;
decltype(&rinhash_cuda_batch) gpu_rinhash_batch; decltype(&rinhash_hip_batch) gpu_rinhash_batch;
decltype(&RinHash) gpu_RinHash; decltype(&RinHash) gpu_RinHash;
// Mining parameters // Mining parameters
@@ -61,30 +62,38 @@ public:
} }
bool loadGPULibrary() { bool loadGPULibrary() {
// Try to load the GPU library // Try to load the GPU library
gpu_lib_handle = dlopen("./rocm-direct-output/gpu-libs/librinhash_hip.so", RTLD_LAZY); std::cout << "Attempting to load GPU library..." << std::endl;
if (!gpu_lib_handle) { gpu_lib_handle = dlopen("./rocm-direct-output/gpu-libs/librinhash_hip.so", RTLD_LAZY);
std::cerr << "Failed to load GPU library: " << dlerror() << std::endl; if (!gpu_lib_handle) {
std::cerr << "Make sure to run: sudo cp rocm-direct-output/gpu-libs/librinhash_hip.so /usr/local/lib/" << std::endl; std::cerr << "Failed to load GPU library: " << dlerror() << std::endl;
return false; std::cerr << "Make sure to run: sudo cp rocm-direct-output/gpu-libs/librinhash_hip.so /usr/local/lib/" << std::endl;
} std::cerr << "Current working directory: " << std::filesystem::current_path() << std::endl;
return false;
}
std::cout << "GPU library loaded successfully!" << std::endl;
// Load function pointers // Load function pointers
gpu_rinhash = (decltype(gpu_rinhash))dlsym(gpu_lib_handle, "rinhash_cuda"); std::cout << "Loading GPU functions..." << std::endl;
gpu_rinhash_batch = (decltype(gpu_rinhash_batch))dlsym(gpu_lib_handle, "rinhash_cuda_batch"); gpu_rinhash = (decltype(gpu_rinhash))dlsym(gpu_lib_handle, "rinhash_hip");
gpu_RinHash = (decltype(gpu_RinHash))dlsym(gpu_lib_handle, "RinHash"); gpu_rinhash_batch = (decltype(gpu_rinhash_batch))dlsym(gpu_lib_handle, "rinhash_hip_batch");
gpu_RinHash = (decltype(gpu_RinHash))dlsym(gpu_lib_handle, "RinHash");
if (!gpu_rinhash || !gpu_rinhash_batch || !gpu_RinHash) { if (!gpu_rinhash) std::cerr << "Failed to load rinhash_hip" << std::endl;
std::cerr << "Failed to load GPU functions: " << dlerror() << std::endl; if (!gpu_rinhash_batch) std::cerr << "Failed to load rinhash_hip_batch" << std::endl;
dlclose(gpu_lib_handle); if (!gpu_RinHash) std::cerr << "Failed to load RinHash" << std::endl;
gpu_lib_handle = nullptr;
return false; if (!gpu_rinhash || !gpu_rinhash_batch || !gpu_RinHash) {
} std::cerr << "Failed to load GPU functions: " << dlerror() << std::endl;
dlclose(gpu_lib_handle);
gpu_lib_handle = nullptr;
return false;
}
std::cout << "GPU functions loaded successfully!" << std::endl;
// GPU availability will be verified by successful library loading // GPU availability will be verified by successful library loading
// and function calls working properly // and function calls working properly
std::cout << "GPU library loaded successfully!" << std::endl;
std::cout << "GPU functions ready for mining" << std::endl; std::cout << "GPU functions ready for mining" << std::endl;
gpu_available = true; gpu_available = true;
@@ -149,7 +158,12 @@ public:
} }
// Process batch on GPU // Process batch on GPU
gpu_rinhash_batch(block_headers.data(), block_header_len, hashes.data(), num_nonces); if (gpu_rinhash_batch) {
gpu_rinhash_batch(block_headers.data(), block_header_len, hashes.data(), num_nonces);
} else {
std::cerr << "GPU batch function not available" << std::endl;
return false;
}
hashes_computed += num_nonces; hashes_computed += num_nonces;
// Check results // Check results

BIN
rin/miner/rinhash-gpu-miner Normal file

Binary file not shown.