Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
secrets:
EXTERNAL_SERVICE_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
with:
nim-versions: '["version-1-6", "version-2-0", "version-2-2", "devel"]'
test-command: |
if [[ "$MATRIX_OS" == "windows" ]]; then
powershell -c "irm https://bencher.dev/download/install-cli.ps1 | iex"
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ jobs:
tests:
uses: status-im/nimbus-common-workflow/.github/workflows/common.yml@main
with:
nim-versions: '["version-1-6", "version-2-0", "version-2-2", "devel"]'
test-command: |
nimble test_asan
nimble test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ nbook

nimcache/

tests/tintops
build/

results.csv
results.json
Expand Down
66 changes: 50 additions & 16 deletions intops.nimble
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mode = ScriptMode.Verbose

# Package

version = "1.0.8"
Expand All @@ -8,26 +10,58 @@ srcDir = "src"

# Dependencies

requires "nim >= 1.6.16", "unittest2 >= 0.2.5"
requires "nim >= 1.6.16", "unittest2 >= 0.3.0"

import std/[os, sequtils, strformat, parseopt, json]

task test, "Run tests":
let
archFlags =
commandLineParams().filterIt(it.startsWith("--cpu") or it.startsWith("--gcc"))
archFlagStr = archFlags.join(" ")

for intopsFlagStr in [
"-d:intopsNoIntrinsics", "-d:intopsNoInlineAsm", "-d:intopsNoInlineC",
"-d:unittest2Static",
"-d:unittest2Static -d:intopsNoIntrinsics -d:intopsNoInlineAsm -d:intopsNoInlineC",
]:
let flags = [intopsFlagStr, archFlagStr].join(" ")
let nimc = getEnv("NIMC", "nim") # Which nim compiler to use
let lang = getEnv("NIMLANG", "c") # Which backend (c/cpp/js)
let flags = getEnv("NIMFLAGS", "") # Extra flags for the compiler
let verbose = getEnv("V", "") notin ["", "0"]
let platform = getEnv("PLATFORM", "")
let testArguments = [
"-d:intopsNoIntrinsics",
"-d:intopsNoInlineAsm",
"-d:intopsNoInlineC",
"-d:unittest2Static",
"-d:unittest2Static -d:intopsNoIntrinsics -d:intopsNoInlineAsm -d:intopsNoInlineC",
]

let cfg =
" --styleCheck:usages --styleCheck:error" &
(if verbose: "" else: " --verbosity:0") &
" --skipParentCfg --skipUserCfg --outdir:build -f " &
quoteShell("--nimcache:build/nimcache/$projectName")

proc build(args, path: string) =
let archFlags =
commandLineParams().filterIt(it.startsWith("--cpu") or it.startsWith("--gcc"))
exec nimc & " " & lang & " " & cfg & " " & flags & " " & archFlags.join(" ") &
" " & args & " " & path

proc run(args, path: string) =
build args & " -r", path

echo fmt"# Flags: {flags}"

selfExec fmt"r {flags} tests/tintops.nim"
task test, "Run tests":
for args in testArguments:
run args & " --mm:refc", "tests/tintops"
run args & " --mm:orc", "tests/tintops"

task test_asan, "Run tests with ASAN":
if platform != "x86":
# https://clang.llvm.org/docs/AddressSanitizer.html
putEnv("ASAN_OPTIONS", "detect_leaks=0:detect_stack_use_after_return=1")
# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
putEnv("UBSAN_OPTIONS", "print_stacktrace=1")
let asanArgs =
" --mm:orc -d:useMalloc --cc:clang --debugger:native" &
" --passC:-fsanitize=address,undefined" &
" --passL:-fsanitize=address,undefined" &
" --passC:-fno-sanitize-recover=undefined" &
" --passC:-fno-sanitize-merge" &
" --passC:-fno-omit-frame-pointer"
for args in testArguments:
run args & asanArgs, "tests/tintops"

task bench, "Run benchmarks":
var
Expand Down
4 changes: 2 additions & 2 deletions src/intops/impl/intrinsics/x86.nim
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ when cpuX86 and canUseIntrinsics:

bool(borrow)

when cpu64bit and cpuX86 and canUseIntrinsics:
when cpu64Bit and cpuX86 and canUseIntrinsics:
func builtinCarryingAdd*(
carry: uint8, a, b: culonglong, res: ptr culonglong
): uint8 {.importc: "_addcarry_u64", x86_header.}
Expand Down Expand Up @@ -101,7 +101,7 @@ when cpu64bit and cpuX86 and canUseIntrinsics:

bool(borrow)

when cpu64bit and cpuX86 and compilerMsvc and canUseIntrinsics:
when cpu64Bit and cpuX86 and compilerMsvc and canUseIntrinsics:
func builtinWideningMul*(
a, b: culonglong, hi: ptr culonglong
): uint64 {.importc: "_umul128", x86_header.}
Expand Down
Loading