meson instead cmake/makefile
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.31)
|
||||
project(yggm)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
file(GLOB ${PROJECT_NAME}SOURCES *.cpp)
|
||||
file(GLOB ${PROJECT_NAME}HEADERS *.h)
|
||||
|
||||
add_executable(${PROJECT_NAME} sources/main.cpp)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/libs)
|
||||
|
||||
if(CMAKE_BUILD_TYPE)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_definitions(-DDEBUG)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
add_definitions(-DRELEASE)
|
||||
endif()
|
||||
elseif(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
|
||||
endif()
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag("-mavx2" HAVE_AVX2)
|
||||
|
||||
if(HAVE_AVX2)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -mavx2)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_AVX2=1)
|
||||
else()
|
||||
message(WARNING "AVX2 not supported: fallback")
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_AVX2=0)
|
||||
endif()
|
||||
|
||||
set(CXX_ADDITIONAL_FLAGS
|
||||
"-fomit-frame-pointer \
|
||||
-funroll-loops \
|
||||
-ftree-vectorize \
|
||||
-ftree-slp-vectorize \
|
||||
-fdelete-null-pointer-checks \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-funsafe-math-optimizations \
|
||||
-fstrict-aliasing \
|
||||
-fstrict-overflow \
|
||||
-fno-stack-protector \
|
||||
-fno-math-errno")
|
||||
|
||||
set(CXXFLAGSR "-march=native -O3 -ffast-math -pipe -Wall -Wextra -Wpedantic -Wconversion -Wuninitialized -Wsign-conversion -flto")
|
||||
set(CXXFLAGSD "-O0 -pipe -Wall -Wextra -Wpedantic -Wconversion -Wuninitialized -Wsign-conversion -g")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CXXFLAGSR} ${CXX_ADDITIONAL_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CXXFLAGSD}")
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} sodium)
|
||||
@@ -1,31 +0,0 @@
|
||||
NVCC := nvcc
|
||||
NVCC_FLAGS := -rdc=true -O3 -Xptxas -O3 \
|
||||
-use_fast_math -ftz=true -prec-div=false -prec-sqrt=false \
|
||||
-gencode arch=compute_75,code=sm_75 \
|
||||
--default-stream per-thread \
|
||||
-Wno-deprecated-gpu-targets \
|
||||
--expt-relaxed-constexpr \
|
||||
-I../libs/ \
|
||||
-std=c++20 --compiler-bindir=/usr/bin/gcc-13
|
||||
BUILD ?= RELEASE
|
||||
ifeq ($(BUILD),DEBUG)
|
||||
BUILD_DEFINES := -DDEBUG
|
||||
else
|
||||
BUILD_DEFINES := -DRELEASE
|
||||
endif
|
||||
MAIN_SOURCE := ../sources/main.cu
|
||||
LIBS_DIR := ../libs/
|
||||
BUILD_DIR := ../build
|
||||
LIBS_SOURCES := $(wildcard $(LIBS_DIR)*.cu)
|
||||
LIBS_OBJECTS := $(patsubst $(LIBS_DIR)%.cu,$(BUILD_DIR)/%.o,$(LIBS_SOURCES))
|
||||
TARGET := yggmcu
|
||||
.PHONY: all clean
|
||||
all: $(TARGET)
|
||||
$(BUILD_DIR):
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
$(TARGET): $(MAIN_SOURCE) $(LIBS_OBJECTS)
|
||||
$(NVCC) $(NVCC_FLAGS) $(BUILD_DEFINES) -o $@ $^
|
||||
$(BUILD_DIR)/%.o: $(LIBS_DIR)%.cu | $(BUILD_DIR)
|
||||
$(NVCC) $(NVCC_FLAGS) $(BUILD_DEFINES) -c $< -o $@
|
||||
clean:
|
||||
@rm -f $(BUILD_DIR)/*.o $(TARGET)
|
||||
54
meson.build
Normal file
54
meson.build
Normal file
@@ -0,0 +1,54 @@
|
||||
project('yggm', ['cpp', 'cuda'],
|
||||
version: '20.08.2025',
|
||||
default_options: ['cpp_std=c++20']
|
||||
)
|
||||
|
||||
common_cpp_flags = [
|
||||
'-march=native',
|
||||
'-pipe',
|
||||
'-Wpedantic',
|
||||
'-Wconversion',
|
||||
'-Wuninitialized',
|
||||
'-Wsign-conversion',
|
||||
'-masm=intel'
|
||||
]
|
||||
|
||||
common_cuda_flags = [
|
||||
'-rdc=true',
|
||||
'-O3',
|
||||
'-Xptxas', '-O3',
|
||||
'-use_fast_math',
|
||||
'-ftz=true',
|
||||
'-prec-div=false',
|
||||
'-prec-sqrt=false',
|
||||
'-gencode', 'arch=compute_75,code=sm_75',
|
||||
'-Wno-deprecated-gpu-targets',
|
||||
'--default-stream', 'per-thread',
|
||||
'--expt-relaxed-constexpr',
|
||||
'-I../libs/',
|
||||
'--compiler-bindir=/usr/bin/gcc-14',
|
||||
]
|
||||
|
||||
add_project_arguments(common_cpp_flags, language: 'cpp')
|
||||
add_project_arguments(common_cuda_flags, language: 'cuda')
|
||||
|
||||
if get_option('buildtype') == 'release'
|
||||
add_project_arguments(['-DRELEASE'], language: ['cpp', 'cuda'])
|
||||
elif get_option('buildtype') == 'debug'
|
||||
add_project_arguments(['-DDEBUG', '-g', '-O0'], language: ['cpp', 'cuda'])
|
||||
endif
|
||||
|
||||
cpp_sources = ['sources/main.cpp']
|
||||
cuda_sources = ['sources/main.cu'] + files(run_command('find', 'libs', '-name', '*.cu').stdout().split())
|
||||
|
||||
yggmcu = executable('yggmcu',
|
||||
sources: cuda_sources,
|
||||
install: true,
|
||||
dependencies: dependency('cuda', modules: ['cudart'], required: false)
|
||||
)
|
||||
|
||||
executable('yggm',
|
||||
sources: cpp_sources,
|
||||
install: true,
|
||||
dependencies: dependency('libsodium')
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <atomic>
|
||||
#include <defines.h>
|
||||
#include "../libs/defines.h"
|
||||
#include <immintrin.h>
|
||||
#include <iostream>
|
||||
#include <memory.h>
|
||||
@@ -55,7 +55,6 @@ inline std::string getAddress(const Address& rawAddr) {
|
||||
inline std::string KeyToString(const unsigned char* key) {
|
||||
char result[65];
|
||||
const char* hexDigits = "0123456789abcdef";
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 32; i++) {
|
||||
result[2 * i] = hexDigits[key[i] >> 4];
|
||||
result[2 * i + 1] = hexDigits[key[i] & 0x0F];
|
||||
@@ -70,9 +69,8 @@ typedef struct alignas(32) {
|
||||
void getRawAddress(unsigned lErase, Key& InvertedPublicKey, Address& rawAddr) {
|
||||
lErase++;
|
||||
const int bitsToShift = lErase % 8;
|
||||
const int start = lErase / 8;
|
||||
const int start = static_cast<int>(lErase / 8U);
|
||||
if (bitsToShift != 0) {
|
||||
#pragma unroll
|
||||
for (int i = start; i < start + 15; i++) {
|
||||
InvertedPublicKey[i] = static_cast<unsigned char>((InvertedPublicKey[i] << bitsToShift) | (InvertedPublicKey[i + 1] >> (8 - bitsToShift)));
|
||||
}
|
||||
@@ -92,7 +90,6 @@ inline void invertKey(const unsigned char* __restrict key, Key& inverted) {
|
||||
}
|
||||
inline unsigned getZeros(const Key& v) {
|
||||
unsigned leadZeros = 0;
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 32; i += 8) {
|
||||
unsigned long long word = (static_cast<unsigned long long>(v[i]) << 56) | (static_cast<unsigned long long>(v[i + 1]) << 48) | (static_cast<unsigned long long>(v[i + 2]) << 40) | (static_cast<unsigned long long>(v[i + 3]) << 32) | (static_cast<unsigned long long>(v[i + 4]) << 24) | (static_cast<unsigned long long>(v[i + 5]) << 16) | (static_cast<unsigned long long>(v[i + 6]) << 8) | static_cast<unsigned long long>(v[i + 7]);
|
||||
if (word == 0) {
|
||||
|
||||
Reference in New Issue
Block a user