mirror of
https://github.com/codex-storage/constantine.git
synced 2025-01-12 03:54:14 +00:00
Move metering report and tracer primitive to inner lib (#289)
* move inner metering to inner lib * remove duplicate getTicks from benchmarks folder
This commit is contained in:
parent
67fbd8c699
commit
07f96ec259
@ -6,25 +6,5 @@
|
|||||||
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
when defined(amd64): # TODO defined(i386) but it seems like RDTSC call is misconfigured
|
import ../constantine/platforms/metering/benchmarking
|
||||||
import platforms/x86
|
export benchmarking
|
||||||
export getTicks, cpuName
|
|
||||||
|
|
||||||
const SupportsCPUName* = true
|
|
||||||
const SupportsGetTicks* = true
|
|
||||||
else:
|
|
||||||
const SupportsCPUName* = false
|
|
||||||
const SupportsGetTicks* = false
|
|
||||||
|
|
||||||
# Prevent compiler optimizing benchmark away
|
|
||||||
# -----------------------------------------------
|
|
||||||
# This doesn't always work unfortunately ...
|
|
||||||
|
|
||||||
proc volatilize(x: ptr byte) {.codegenDecl: "$# $#(char const volatile *x)", inline.} =
|
|
||||||
discard
|
|
||||||
|
|
||||||
template preventOptimAway*[T](x: var T) =
|
|
||||||
volatilize(cast[ptr byte](unsafeAddr x))
|
|
||||||
|
|
||||||
template preventOptimAway*[T](x: T) =
|
|
||||||
volatilize(cast[ptr byte](x))
|
|
@ -4,8 +4,6 @@ author = "Mamy Ratsimbazafy"
|
|||||||
description = "This library provides thoroughly tested and highly-optimized implementations of cryptography protocols."
|
description = "This library provides thoroughly tested and highly-optimized implementations of cryptography protocols."
|
||||||
license = "MIT or Apache License 2.0"
|
license = "MIT or Apache License 2.0"
|
||||||
|
|
||||||
installDirs = @["constantine", "metering"]
|
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# ############################################################
|
# ############################################################
|
||||||
|
|
||||||
import ./primitives
|
import ./primitives
|
||||||
import ../../metering/tracer
|
import ./metering/tracer
|
||||||
|
|
||||||
export primitives, tracer
|
export primitives, tracer
|
||||||
|
|
||||||
|
30
constantine/platforms/metering/benchmarking.nim
Normal file
30
constantine/platforms/metering/benchmarking.nim
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Constantine
|
||||||
|
# Copyright (c) 2018-2019 Status Research & Development GmbH
|
||||||
|
# Copyright (c) 2020-Present Mamy André-Ratsimbazafy
|
||||||
|
# Licensed and distributed under either of
|
||||||
|
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
|
||||||
|
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
|
when defined(amd64): # TODO defined(i386) but it seems like RDTSC call is misconfigured
|
||||||
|
import cycle_count/x86
|
||||||
|
export getTicks, cpuName
|
||||||
|
|
||||||
|
const SupportsCPUName* = true
|
||||||
|
const SupportsGetTicks* = true
|
||||||
|
else:
|
||||||
|
const SupportsCPUName* = false
|
||||||
|
const SupportsGetTicks* = false
|
||||||
|
|
||||||
|
# Prevent compiler optimizing benchmark away
|
||||||
|
# -----------------------------------------------
|
||||||
|
# This doesn't always work unfortunately ...
|
||||||
|
|
||||||
|
proc volatilize(x: ptr byte) {.codegenDecl: "$# $#(char const volatile *x)", inline.} =
|
||||||
|
discard
|
||||||
|
|
||||||
|
template preventOptimAway*[T](x: var T) =
|
||||||
|
volatilize(cast[ptr byte](unsafeAddr x))
|
||||||
|
|
||||||
|
template preventOptimAway*[T](x: T) =
|
||||||
|
volatilize(cast[ptr byte](x))
|
@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
std/[strformat, strutils],
|
std/[strformat, strutils],
|
||||||
../benchmarks/platforms,
|
./benchmarking,
|
||||||
tracer
|
./tracer
|
||||||
|
|
||||||
# Reporting benchmark result
|
# Reporting benchmark result
|
||||||
# -------------------------------------------------------
|
# -------------------------------------------------------
|
@ -20,7 +20,7 @@ const CTT_TRACE {.booldefine.} = off # For manual "debug-echo"-style timing.
|
|||||||
|
|
||||||
when CTT_METER or CTT_TRACE:
|
when CTT_METER or CTT_TRACE:
|
||||||
|
|
||||||
import ../benchmarks/platforms
|
import ./benchmarking
|
||||||
|
|
||||||
type
|
type
|
||||||
Metadata* = object
|
Metadata* = object
|
@ -7,7 +7,7 @@
|
|||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
import
|
import
|
||||||
./reports, ./tracer,
|
../constantine/platforms/metering/[reports, tracer],
|
||||||
../constantine/ethereum_evm_precompiles,
|
../constantine/ethereum_evm_precompiles,
|
||||||
../constantine/platforms/abstractions
|
../constantine/platforms/abstractions
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
std/times,
|
std/times,
|
||||||
./reports, ./tracer,
|
../constantine/platforms/metering/[reports, tracer],
|
||||||
../constantine/math/config/curves,
|
../constantine/math/config/curves,
|
||||||
../constantine/math/[arithmetic, extension_fields, ec_shortweierstrass],
|
../constantine/math/[arithmetic, extension_fields, ec_shortweierstrass],
|
||||||
../constantine/math/constants/zoo_subgroups,
|
../constantine/math/constants/zoo_subgroups,
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
std/times,
|
std/times,
|
||||||
./reports, ./tracer,
|
../constantine/platforms/metering/[reports, tracer],
|
||||||
../constantine/math/config/curves,
|
../constantine/math/config/curves,
|
||||||
../constantine/math/[arithmetic, extension_fields, ec_shortweierstrass],
|
../constantine/math/[arithmetic, extension_fields, ec_shortweierstrass],
|
||||||
../constantine/math/constants/zoo_subgroups,
|
../constantine/math/constants/zoo_subgroups,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user