Skip to content

Commit

Permalink
Use new adix/cpuCT set[enum] to test flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
c-blake committed Jun 18, 2023
1 parent a96898d commit dab6dc9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
6 changes: 4 additions & 2 deletions adix/cumsum.nim
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#{.push hint[LineTooLong]:off.} # Tabular readability trumps 80-col niceness
import adix/cpuCT

Check failure on line 1 in adix/cumsum.nim

View workflow job for this annotation

GitHub Actions / ubuntu-latest (version-1-6)

cannot open file: adix/cpuCT

proc cumsum*[T](c: ptr UncheckedArray[T]; n: uint) =
for i in 1 ..< n:
c[i] += c[i - 1]

when defined(amd64) and not defined(usePortable): #usePortable nice for timing
#NOTE: SSSE3 => SSE2 which is also used.
when defined(amd64) and not defined(noSIMD) and x86ssse3 in x86features:

Check failure on line 8 in adix/cumsum.nim

View workflow job for this annotation

GitHub Actions / ubuntu-latest (version-1-6)

undeclared identifier: 'x86features'

Check failure on line 8 in adix/cumsum.nim

View workflow job for this annotation

GitHub Actions / ubuntu-latest (version-1-6)

undeclared identifier: 'x86ssse3'

Check failure on line 8 in adix/cumsum.nim

View workflow job for this annotation

GitHub Actions / ubuntu-latest (version-1-6)

cannot generate code for: x86features
when defined(cpuPrefetch): import cligen/prefetch

template workToAligned(c, n, i, align: untyped) {.dirty.} =
Expand Down
12 changes: 2 additions & 10 deletions adix/nsort.nim
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,13 @@
## cheap compared to L2 or worse bandwidth costs. So, 5-20% boost, I'd guess.)

when not declared(stdout): import std/syncio
import bitops, math, algorithm, cumsum
import adix/[cpuCT, cumsum], std/[bitops, math, algorithm]

Check failure on line 58 in adix/nsort.nim

View workflow job for this annotation

GitHub Actions / ubuntu-latest (version-1-6)

cannot open file: adix/cpuCT
when defined(cpuPrefetch): import cligen/prefetch # Keep cligen a soft-dep
const nTinySort{.intdefine.} = 24 # Usually 16-32 is good
const hMaxBits{.intdefine.} = 15 #2*counter-size*2**hMaxBits =~ L2 here
const dGiantSort{.intdefine.} = 15 shl 30 #~50% of uncontended DIMM storage

const haveBMI2 =
when defined(amd64) and not defined(noSIMD):
when defined(gcc): # ||||||||||||| gcc.options here (for X-compiles)
staticExec("touch j.c;gcc -march=native -dM -E j.c|grep __BMI2__;rm -f j.c").len > 0
elif defined(clang):
staticExec("touch j.c;clang -march=native -dM -E j.c|grep __BMI2__;rm -f j.c").len > 0
else: false

when haveBMI2:
when defined(amd64) and not defined(noSIMD) and x86bmi2 in x86features:

Check failure on line 64 in adix/nsort.nim

View workflow job for this annotation

GitHub Actions / ubuntu-latest (version-1-6)

undeclared identifier: 'x86features'

Check failure on line 64 in adix/nsort.nim

View workflow job for this annotation

GitHub Actions / ubuntu-latest (version-1-6)

undeclared identifier: 'x86bmi2'

Check failure on line 64 in adix/nsort.nim

View workflow job for this annotation

GitHub Actions / ubuntu-latest (version-1-6)

cannot generate code for: x86features
proc pext(val,msk:uint32):uint32 {.importc:"_pext_u32", header:"x86intrin.h".}
proc pext(val,msk:uint64):uint64 {.importc:"_pext_u64", header:"x86intrin.h".}
else:
Expand Down

0 comments on commit dab6dc9

Please sign in to comment.