Skip to content
Permalink
Browse files

Support for supercop ASM in wallet, and benchmark for supercop

  • Loading branch information
vtnerd committed Nov 15, 2019
1 parent 6b2b1d6 commit 28450e987da07df9ba64b52d52cb65e33aab6864
@@ -15,3 +15,7 @@
[submodule "external/randomx"]
path = external/randomx
url = https://github.com/tevador/RandomX
[submodule "external/supercop"]
path = external/supercop
url = https://github.com/monero-project/supercop
branch = monero
@@ -203,6 +203,7 @@ if(NOT MANUAL_SUBMODULES)
check_submodule(external/rapidjson)
check_submodule(external/trezor-common)
check_submodule(external/randomx)
check_submodule(external/supercop)
endif()
endif()

@@ -298,7 +299,7 @@ endif()
# elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
# set(BSDI TRUE)

include_directories(external/rapidjson/include external/easylogging++ src contrib/epee/include external)
include_directories(external/rapidjson/include external/easylogging++ src contrib/epee/include external external/supercop/include)

if(APPLE)
include_directories(SYSTEM /usr/include/malloc)
@@ -443,6 +444,9 @@ add_definition_if_function_found(strptime HAVE_STRPTIME)

add_definitions(-DAUTO_INITIALIZE_EASYLOGGINGPP)

set(MONERO_GENERATED_HEADERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated_include")
include_directories(${MONERO_GENERATED_HEADERS_DIR})

# Generate header for embedded translations
# Generate header for embedded translations, use target toolchain if depends, otherwise use the
# lrelease and lupdate binaries from the host
@@ -116,3 +116,6 @@ endif()

# cheat because cmake and ccache hate each other
set_property(SOURCE CryptonightR_template.S PROPERTY LANGUAGE C)

# Must be done last, because it references libraries in this directory
add_subdirectory(wallet)
@@ -0,0 +1,87 @@
# Copyright (c) 2020, The Monero Project
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#
# Possibly user defined values.
#
set(MONERO_WALLET_CRYPTO_LIBRARY "auto" CACHE STRING "Select a wallet crypto library")
set(MONERO_WALLET_CRYPTO_BENCH "cn" CACHE STRING "Select wallet crypto libraries for benchmarking")

include(${PROJECT_SOURCE_DIR}/external/supercop/functions.cmake)

#
# If the user specified "auto", detect best library defaulting to internal.
#
if (${MONERO_WALLET_CRYPTO_LIBRARY} STREQUAL "auto")
monero_crypto_autodetect(AVAILABLE BEST)
if (DEFINED AVAILABLE AND DEFINED BEST)
set(MONERO_WALLET_CRYPTO_LIBRARY ${BEST})
list(APPEND MONERO_WALLET_CRYPTO_BENCH ${AVAILABLE})
else ()
message("Defaulting to internal crypto library for wallet")
set(MONERO_WALLET_CRYPTO_LIBRARY "cn")
endif ()
endif ()

#
# Configure library target "wallet-crypto" - clients will use this as a
# library dependency which in turn will depend on the crypto library selected.
#
if (${MONERO_WALLET_CRYPTO_LIBRARY} STREQUAL "cn")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/empty.h.in ${MONERO_GENERATED_HEADERS_DIR}/crypto/wallet/ops.h)
add_library(wallet-crypto ALIAS cncrypto)
else ()
monero_crypto_generate_header(${MONERO_WALLET_CRYPTO_LIBRARY} "${MONERO_GENERATED_HEADERS_DIR}/crypto/wallet/ops.h")
monero_crypto_get_target(${MONERO_WALLET_CRYPTO_LIBRARY} CRYPTO_TARGET)
add_library(wallet-crypto $<TARGET_OBJECTS:${CRYPTO_TARGET}>)
target_link_libraries(wallet-crypto cncrypto)
endif ()

#
# Configure optional benchmark utility - not built by defalt
#
list(REMOVE_DUPLICATES MONERO_WALLET_CRYPTO_BENCH)
list(REMOVE_ITEM MONERO_WALLET_CRYPTO_BENCH "cn") # always used for comparison
set(MONERO_WALLET_CRYPTO_BENCH_NAMES "(cn)")
foreach(BENCH IN LISTS MONERO_WALLET_CRYPTO_BENCH)
monero_crypto_valid(${BENCH} VALID)
if (NOT VALID)
message(FATAL_ERROR "Invalid MONERO_WALLET_CRYPTO_BENCH option ${BENCH}")
endif ()

monero_crypto_get_target(${BENCH} BENCH_LIBRARY)
list(APPEND BENCH_LIBRARIES ${BENCH_LIBRARY})

monero_crypto_get_namespace(${BENCH} BENCH_NAMESPACE)
set(MONERO_WALLET_CRYPTO_BENCH_NAMES "${MONERO_WALLET_CRYPTO_BENCH_NAMES}(${BENCH_NAMESPACE})")
endforeach ()

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/benchmark.h.in" "${MONERO_GENERATED_HEADERS_DIR}/crypto/wallet/benchmark.h")
add_executable(monero-wallet-crypto-bench EXCLUDE_FROM_ALL benchmark.cpp)
target_link_libraries(monero-wallet-crypto-bench cncrypto ${BENCH_LIBRARIES})

0 comments on commit 28450e9

Please sign in to comment.
You can’t perform that action at this time.