Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chiapos wheels #302

Draft
wants to merge 32 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0adf85f
Extract version.
fchirica Mar 1, 2023
db1d20e
Add sys/errno.h
fchirica Mar 1, 2023
d254c13
Try cast to uint64.
fchirica Mar 1, 2023
e2dddac
Test.
fchirica Mar 1, 2023
0cbe9a6
Version.
fchirica Mar 2, 2023
9e0436d
Version.
fchirica Mar 2, 2023
8192955
Update extract-version.sh
fchirica Mar 2, 2023
7642091
revert.
fchirica Mar 2, 2023
e461efb
debug.
fchirica Mar 3, 2023
105b0c7
debug.
fchirica Mar 3, 2023
e78d847
Try random.h
fchirica Mar 3, 2023
c7315d1
Try to remove COMMAND_ERROR_IS_FATAL
fchirica Mar 3, 2023
20640f8
Update SysHost_Linux.cpp
fchirica Mar 3, 2023
59ccb6b
Update CMakeLists.txt
fchirica Mar 3, 2023
7b4ce95
revert.
fchirica Mar 3, 2023
9afa598
Update SysHost_Linux.cpp
fchirica Mar 3, 2023
9c67d7e
Update SysHost_Linux.cpp
fchirica Mar 3, 2023
2a0d313
Update SysHost_Linux.cpp
fchirica Mar 3, 2023
6896890
Try with syscall.
fchirica Mar 3, 2023
696f90b
Update extract-version.sh
fchirica Mar 3, 2023
bd9706d
Update SysHost_Linux.cpp
fchirica Mar 3, 2023
5fd685c
Merge branch 'chiapos-bladebit' into chiapos
fchirica Mar 6, 2023
cb1097e
Update TestCompressedPlotProof.cpp
fchirica Mar 6, 2023
637d660
Merge branch 'cuda-compression' into chiapos
fchirica Mar 10, 2023
7c3f00a
Try /dev/urandom
fchirica Mar 10, 2023
5e52654
Merge branch 'cuda-compression' into chiapos
fchirica Mar 14, 2023
4fb1c59
Disable -march=native on non-CI builds
harold-b Mar 14, 2023
e8c7362
Introduce a build option around bladebit tests.
AmineKhaldi Mar 20, 2023
91aa4bf
Fix MSVC build.
AmineKhaldi Mar 20, 2023
50bafa2
Merge pull request #309 from AmineKhaldi/fix_msvc_build
fchirica Mar 20, 2023
73b0991
Merge pull request #308 from AmineKhaldi/feature_flag_tests
fchirica Mar 20, 2023
197a833
Merge branch 'cuda-compression' into chiapos
fchirica Apr 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 65 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules
)

option(BLADEBIT_ENABLE_TESTS "Enable bladebit tests." ON)

#
# Grab Dependencies
Expand Down Expand Up @@ -80,14 +81,13 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(platform_libs ${NUMA_LIBRARY})
endif()



# Catch
# TODO: Add configuration var to disable this
include(cmake_modules/FindCatch2.cmake)
# set_target_properties(Catch2 PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# set_target_properties(Catch2WithMain PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

if(BLADEBIT_ENABLE_TESTS)
# Catch
include(cmake_modules/FindCatch2.cmake)
include_directories(/usr/include)
# set_target_properties(Catch2 PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# set_target_properties(Catch2WithMain PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

# Config
set(c_opts)
Expand Down Expand Up @@ -131,11 +131,55 @@ if((NOT DEFINED ENV{CI}) AND (NOT DEFINED CACHE{bb_version_embedded}))
set(cmd_ver bash.exe)
endif()

execute_process(COMMAND ${cmd_ver} extract-version.sh major OUTPUT_VARIABLE bb_ver_maj WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND_ERROR_IS_FATAL ANY)
execute_process(COMMAND ${cmd_ver} extract-version.sh minor OUTPUT_VARIABLE bb_ver_min WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND_ERROR_IS_FATAL ANY)
execute_process(COMMAND ${cmd_ver} extract-version.sh revision OUTPUT_VARIABLE bb_ver_rev WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND_ERROR_IS_FATAL ANY)
execute_process(COMMAND ${cmd_ver} extract-version.sh suffix OUTPUT_VARIABLE bb_ver_suffix WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND_ERROR_IS_FATAL ANY)
execute_process(COMMAND ${cmd_ver} extract-version.sh commit OUTPUT_VARIABLE bb_ver_commit WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND_ERROR_IS_FATAL ANY)
execute_process(
COMMAND ${cmd_ver} extract-version.sh major
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE bb_ver_maj
RESULT_VARIABLE result_maj
)
if(result_maj)
message(FATAL_ERROR "Failed to extract major version")
endif()

execute_process(
COMMAND ${cmd_ver} extract-version.sh minor
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE bb_ver_min
RESULT_VARIABLE result_min
)
if(result_min)
message(FATAL_ERROR "Failed to extract minor version")
endif()

execute_process(
COMMAND ${cmd_ver} extract-version.sh revision
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE bb_ver_rev
RESULT_VARIABLE result_rev
)
if(result_rev)
message(FATAL_ERROR "Failed to extract revision")
endif()

execute_process(
COMMAND ${cmd_ver} extract-version.sh suffix
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE bb_ver_suffix
RESULT_VARIABLE result_suffix
)
if(result_suffix)
message(FATAL_ERROR "Failed to extract suffix")
endif()

execute_process(
COMMAND ${cmd_ver} extract-version.sh commit
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE bb_ver_commit
RESULT_VARIABLE result_commit
)
if(result_commit)
message(FATAL_ERROR "Failed to extract commit")
endif()

# Remove trailing whitespace incurred in windows gitbash
string(STRIP "${bb_ver_maj}" bb_ver_maj)
Expand Down Expand Up @@ -263,9 +307,10 @@ else()
# set(c_opts -ffat-lto-objects ${c_opts})

# Build with native architecture when not building release packages
if(NOT DEFINED ENV{CI})
set(c_opts -march=native ${c_opts})
endif()
# NOTE: Disabled for now to avoid issue when building chiapos wheels
# if(NOT DEFINED ENV{CI})
# set(c_opts -march=native ${c_opts})
# endif()

# Clang
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
Expand Down Expand Up @@ -308,10 +353,12 @@ list(FILTER bb_sources EXCLUDE REGEX "src/uint128_t/.+")


# Project-specific sources
if(BLADEBIT_ENABLE_TESTS)
file(GLOB_RECURSE src_tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
CONFIGURE_DEPENDS LIST_DIRECTORIES false
tests/*.cpp
)
endif()

file(GLOB_RECURSE src_dev RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
CONFIGURE_DEPENDS LIST_DIRECTORIES false
Expand Down Expand Up @@ -440,7 +487,7 @@ target_compile_options(bladebit PRIVATE $<$<CONFIG:Debug>:${c_opts} ${debug_c_op
target_compile_options(bladebit PRIVATE ${bb_c_opts})
target_link_libraries(bladebit PRIVATE lib_bladebit)

# Tests

add_executable(tests ${src_tests} ${bb_headers})
target_compile_options(tests PRIVATE $<$<CONFIG:Release>:${c_opts} ${release_c_opts} ${tests_c_opts}>)
target_compile_options(tests PRIVATE $<$<CONFIG:Debug>:${c_opts} ${debug_c_opts} ${tests_c_opts}>)
Expand Down Expand Up @@ -553,4 +600,4 @@ set_target_properties(lib_bladebit_cuda bladebit_cuda PROPERTIES
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src
FILES ${src_full} ${bb_headers}
)
endif() # CUDAToolkit_FOUND
endif() # CUDAToolkit_FOUND
8 changes: 5 additions & 3 deletions extract-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ if [[ -n "$bb_version_suffix" ]] && [[ "${bb_version_suffix:0:1}" != "-" ]]; the
bb_version_suffix="-${bb_version_suffix}"
fi

bb_ver_maj=$(printf $version_str | sed -E -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/' | xargs)
bb_ver_min=$(printf $version_str | sed -E -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\2/' | xargs)
bb_ver_rev=$(printf $version_str | sed -E -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\3/' | xargs)

IFS='.' read -ra version <<< "$version_str"
bb_ver_maj=${version[0]}
bb_ver_min=${version[1]}
bb_ver_rev=${version[2]}

bb_git_commit=$GITHUB_SHA
if [[ -z $bb_git_commit ]]; then
Expand Down
26 changes: 16 additions & 10 deletions src/platform/linux/SysHost_Linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#include "Platform.h"
#include "util/Util.h"

#include <sys/random.h>

#include <fcntl.h>
#include <unistd.h>

#include <execinfo.h>
#include <signal.h>
#include <atomic>
Expand Down Expand Up @@ -257,9 +260,12 @@ void SysHost::DumpStackTrace()
}

//-----------------------------------------------------------
void SysHost::Random( byte* buffer, size_t size )
{
// See: https://man7.org/linux/man-pages/man2/getrandom.2.html
void SysHost::Random(byte* buffer, size_t size) {
int fd = open("/dev/urandom", O_RDONLY);
if (fd == -1) {
// handle the error
Fatal("Failed to open /dev/urandom.");
}

ssize_t sizeRead;
byte* writer = buffer;
Expand All @@ -272,16 +278,16 @@ void SysHost::Random( byte* buffer, size_t size )
size_t readSize = (size_t)(end - writer);
if( readSize > BLOCK_SIZE )
readSize = BLOCK_SIZE;

sizeRead = getrandom( writer, readSize, 0 );
sizeRead = read(fd, writer, readSize);

// Should never get EINTR, but docs say to check anyway.
int err = errno;
if( sizeRead < 0 && err != EINTR )
Fatal( "getrandom syscall failed with error %d.", err );
if (sizeRead < 0) {
Fatal("read failed with error %d.", errno);
}

writer += (size_t)sizeRead;
}

close(fd);
}

// #NOTE: This is not thread-safe
Expand Down
1 change: 1 addition & 0 deletions src/platform/unix/FileStream_Unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/errno.h>

//----------------------------------------------------------
bool FileStream::Open( const char* path, FileMode mode, FileAccess access, FileFlags flags )
Expand Down
4 changes: 3 additions & 1 deletion src/threading/AutoResetSignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#include "util/Log.h"

#if PLATFORM_IS_WINDOWS
#include <Windows.h>
#include <windows.h>
#else
#include <sys/errno.h>
#endif

//-----------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion tests/TestCompressedPlotProof.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
#include "TestUtil.h"
#include "harvesting/GreenReaper.h"
#include "tools/PlotReader.h"
Expand Down Expand Up @@ -390,4 +391,5 @@ bool GetProofForChallenge( PlotReader& reader, const uint32 f7, uint64 fullProof
void Sha256( byte outHash[32], const byte* bytes, const size_t length )
{
bls::Util::Hash256( outHash, bytes, length );
}
}
*/
4 changes: 2 additions & 2 deletions tests/TestLinePointDeltas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void CalculateParkSizes( const Span<uint64> linePoints, const uint32 stubBitSize

while( entries.Length() > 0 )
{
const uint64 entryCount = std::min( entries.Length(), (size_t)kEntriesPerPark );
const uint64 entryCount = std::min( (size_t) entries.Length(), (size_t)kEntriesPerPark );
entries.SliceSize( entryCount ).CopyTo( Span<uint64>( parkEntries, entryCount ) );

const size_t parkSize = WritePark( parkBufferSize*4, entryCount, parkEntries, parkBuffer, stubBitSize, cTable );
Expand Down Expand Up @@ -263,7 +263,7 @@ void DumpLpData( Span<uint64> linePoints, const uint32 compressionLevel, const u
// Deltafy
for( uint64 park = parkOffset; park < parkEnd; park++ )
{
const uint64 parkEntryCount = std::min( linePoints.Length(), (size_t)kEntriesPerPark );
const uint64 parkEntryCount = std::min( (size_t)linePoints.Length(), (size_t)kEntriesPerPark );

uint64 prevLp = linePoints[0];

Expand Down