-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c86afcc
Showing
20 changed files
with
3,182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
--- | ||
Language: Cpp | ||
# BasedOnStyle: Google | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveMacros: false | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlines: Left | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllConstructorInitializersOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: Never | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: All | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: WithoutElse | ||
AllowShortLoopsOnASingleLine: true | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: true | ||
AlwaysBreakTemplateDeclarations: Yes | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: false | ||
AfterControlStatement: false | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
AfterExternBlock: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Attach | ||
BreakBeforeInheritanceComma: false | ||
BreakInheritanceList: BeforeColon | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakConstructorInitializers: BeforeColon | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakStringLiterals: true | ||
ColumnLimit: 80 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DeriveLineEnding: true | ||
DerivePointerAlignment: true | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: true | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IncludeBlocks: Regroup | ||
IncludeCategories: | ||
- Regex: '^<ext/.*\.h>' | ||
Priority: 2 | ||
SortPriority: 0 | ||
- Regex: '^<.*\.h>' | ||
Priority: 1 | ||
SortPriority: 0 | ||
- Regex: '^<.*' | ||
Priority: 2 | ||
SortPriority: 0 | ||
- Regex: '.*' | ||
Priority: 3 | ||
SortPriority: 0 | ||
IncludeIsMainRegex: '([-_](test|unittest))?$' | ||
IncludeIsMainSourceRegex: '' | ||
IndentCaseLabels: true | ||
IndentGotoLabels: true | ||
IndentPPDirectives: None | ||
IndentWidth: 2 | ||
IndentWrappedFunctionNames: false | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Never | ||
ObjCBlockIndentWidth: 2 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 1 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 200 | ||
PointerAlignment: Left | ||
RawStringFormats: | ||
- Language: Cpp | ||
Delimiters: | ||
- cc | ||
- CC | ||
- cpp | ||
- Cpp | ||
- CPP | ||
- 'c++' | ||
- 'C++' | ||
CanonicalDelimiter: '' | ||
BasedOnStyle: google | ||
- Language: TextProto | ||
Delimiters: | ||
- pb | ||
- PB | ||
- proto | ||
- PROTO | ||
EnclosingFunctions: | ||
- EqualsProto | ||
- EquivToProto | ||
- PARSE_PARTIAL_TEXT_PROTO | ||
- PARSE_TEST_PROTO | ||
- PARSE_TEXT_PROTO | ||
- ParseTextOrDie | ||
- ParseTextProtoOrDie | ||
CanonicalDelimiter: '' | ||
BasedOnStyle: google | ||
ReflowComments: true | ||
SortIncludes: true | ||
SortUsingDeclarations: true | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyBlock: false | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 2 | ||
SpacesInAngles: false | ||
SpacesInConditionalStatement: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
SpaceBeforeSquareBrackets: false | ||
Standard: Auto | ||
StatementMacros: | ||
- Q_UNUSED | ||
- QT_REQUIRE_VERSION | ||
TabWidth: 8 | ||
UseCRLF: false | ||
UseTab: Never | ||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build | ||
.vscode | ||
rust/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
cmake_minimum_required(VERSION 3.24 FATAL_ERROR) | ||
|
||
if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES) | ||
set(CMAKE_CUDA_ARCHITECTURES "all") | ||
endif() | ||
|
||
if (DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") | ||
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) | ||
else() | ||
set(CMAKE_BUILD_TYPE RELEASE) | ||
endif() | ||
|
||
project(spacemesh-cuda LANGUAGES CXX CUDA) | ||
add_compile_options(-fPIC) | ||
|
||
include(FetchContent) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
file(GLOB_RECURSE src_files LIST_DIRECTORIES false src/*.cu src/*.cpp src/*.c) | ||
|
||
include_directories(include) | ||
include_directories(src) | ||
|
||
add_library(${PROJECT_NAME} ${src_files}) | ||
|
||
install(TARGETS ${PROJECT_NAME}) | ||
|
||
option(WITH_TEST "with test" OFF) | ||
|
||
if(${WITH_TEST}) | ||
enable_testing() | ||
set(TEST_EXE ${PROJECT_NAME}-test) | ||
|
||
if (DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") | ||
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) | ||
else() | ||
set(CMAKE_BUILD_TYPE RELEASE) | ||
endif() | ||
|
||
if(${CMAKE_BUILD_TYPE} STREQUAL "RELEASE") | ||
set(NVCC_FLAGS -O3 -Wno-deprecated-gpu-targets --Werror all-warnings) | ||
message(STATUS "${TEST_EXE} compile cuda code in release mode") | ||
else() | ||
set(NVCC_FLAGS -G -Wno-deprecated-gpu-targets --Werror all-warnings) | ||
message(STATUS "${TEST_EXE} compile cuda code in debug mode") | ||
endif() | ||
|
||
#Google Unit Test | ||
option(BUILD_GMOCK "" OFF) | ||
option(INSTALL_GTEST "" OFF) | ||
FetchContent_Declare( | ||
googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG release-1.12.1 | ||
) | ||
FetchContent_MakeAvailable(googletest) | ||
|
||
file(GLOB_RECURSE test_files LIST_DIRECTORIES false test/*.cpp test/*.c test/*.cu) | ||
add_executable(${TEST_EXE} ${test_files}) | ||
set_target_properties(${TEST_EXE} PROPERTIES CUDA_ARCHITECTURES "native") | ||
target_link_libraries(${TEST_EXE} | ||
PRIVATE ${PROJECT_NAME} | ||
PRIVATE gtest | ||
PRIVATE gtest_main) | ||
include(GoogleTest) | ||
set(NVCC_FLAGS ${NVCC_FLAGS})# "SHELL:-t 0" "SHELL:-split-compile 0") | ||
target_compile_options(${TEST_EXE} PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--forward-unknown-opts -Wall ${NVCC_FLAGS}> | ||
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wall>) | ||
add_test(NAME test_corr COMMAND ${TEST_EXE} --gtest_filter=*CheckResult*) | ||
add_test(NAME test_perf COMMAND ${TEST_EXE} --gtest_filter=*Perf*) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 ZakuroLab | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<h1 align="center">Spacemesh-cuda is a library for plot acceleration using CUDA-enabled GPUs.</h1> | ||
|
||
[![license](https://img.shields.io/packagist/l/doctrine/orm.svg)](https://github.com/ZakuroLab/spacemesh-cuda/blob/master/LICENSE) | ||
[![release](https://img.shields.io/github/v/release/ZakuroLab/spacemesh-cuda?include_prereleases)](https://github.com/ZakuroLab/spacemesh-cuda/releases) | ||
![platform](https://img.shields.io/badge/platform-%20linux--64-lightgrey.svg) | ||
[![open help wanted issues](https://img.shields.io/github/issues-raw/ZakuroLab/spacemesh-cuda/help%20wanted?logo=github)](https://github.com/ZakuroLab/spacemesh-cuda/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) | ||
[![made by](https://img.shields.io/badge/madeby-ZakuroLab-blue.svg)](https://github.com/ZakuroLab) | ||
|
||
## <a name='TableofContents'></a>Table of Contents | ||
|
||
* [1. Overview](#1-overview) | ||
* [2. Performance](#2-performance) | ||
* [3. Build & Integration Guide](#3-build-&-integration-guide) | ||
* [3.1 From source](#31-From-source) | ||
* [3.2 From binary](#32-From-binary) | ||
* [4. License](#4-license) | ||
|
||
## 1. Overview | ||
|
||
__spacemesh-cuda__ is a cuda library for plot acceleration for [spacemesh](https://github.com/spacemeshos/go-spacemesh). | ||
This library optimizes memory access, calculation parallelism, etc. Compared with the official program, the library improved by **86.6%**. | ||
|
||
## 2. Performance | ||
| GPU\Library | Official | spacemesh-cuda | | ||
| ---- | --- | ---- | | ||
| RTX3080 | 3.2MB/s | 5.97MB/s | | ||
|
||
## 3. Build & Integration Guide | ||
|
||
### 3.1 From source | ||
```shell | ||
# build libpost.so | ||
git clone https://github.com/ZakuroLab/post-rs.git && cd post-rs/ffi | ||
cargo build --release | ||
cd ../../ | ||
|
||
# get postcli | ||
wget https://github.com/spacemeshos/post/releases/download/v0.12.5/postcli-Linux.zip | ||
unzip -d postcli ./postcli-Linux.zip | ||
cd postcli && mv ../post-rs/target/release/libpost.so ./ | ||
``` | ||
|
||
### 3.2 From binary | ||
```shell | ||
mkdir postcli && cd postcli | ||
wget https://github.com/ZakuroLab/spacemesh-cuda/releases/download/v0.0.1/libpost.so | ||
wget https://github.com/ZakuroLab/spacemesh-cuda/releases/download/v0.0.1/postcli | ||
``` | ||
|
||
## 4. License | ||
|
||
We welcome all contributions to `spacemesh-cuda`. Please refer to the [license](#4-license) for the terms of contributions. | ||
|
||
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
HOME_DIR=`pwd` | ||
rm -rf ${HOME_DIR}/build | ||
mkdir ${HOME_DIR}/build | ||
cmake -DCMAKE_BUILD_TYPE=Release -S ${HOME_DIR} -B ${HOME_DIR}/build -DWITH_TEST=ON | ||
cmake --build ${HOME_DIR}/build -j |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef SPACEMESH_CUDA_SPACEMESH_H | ||
#define SPACEMESH_CUDA_SPACEMESH_H | ||
|
||
#include <stdint.h> | ||
|
||
extern "C" { | ||
/** | ||
* Obtain the number of devices (CUDA GPU) | ||
* | ||
* @returns A uint32 | ||
*/ | ||
uint32_t spacemesh_get_device_num(); | ||
|
||
/** | ||
* Obtain the maximum number of tasks of device @p device_id | ||
* | ||
* @returns A uint32 | ||
*/ | ||
uint32_t spacemesh_get_max_task_num(uint32_t device_id); | ||
|
||
/** | ||
* Execution | ||
* | ||
* @param device_id The index of device | ||
* @param starting_index | ||
* @param input Input CPU memory | ||
* @param task_num The number of tasks | ||
* @param output Output CPU memory | ||
*/ | ||
void spacemesh_scrypt(uint32_t device_id, const uint64_t starting_index, | ||
const uint32_t* input, const uint32_t task_num, | ||
uint32_t* output); | ||
} | ||
|
||
#endif // SPACEMESH_CUDA_SPACEMESH_H |
Oops, something went wrong.