Skip to content

Commit

Permalink
fix(nvidia): reorg + rename following #402
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Jul 20, 2024
1 parent 261f9dd commit 21b072a
Show file tree
Hide file tree
Showing 22 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion constantine/hashes/sha256/sha256_x86_shaext.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
constantine/platforms/isa/simd_x86,
constantine/platforms/x86/simd_x86,
constantine/platforms/primitives,
./sha256_generic

Expand Down
2 changes: 1 addition & 1 deletion constantine/hashes/sha256/sha256_x86_ssse3.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
constantine/platforms/isa/simd_x86,
constantine/platforms/x86/simd_x86,
constantine/platforms/primitives,
./sha256_generic

Expand Down
4 changes: 2 additions & 2 deletions constantine/math/extension_fields/towers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ type
CubicExt[Fp2[Name]]

Fp12*[Name: static Algebra] =
CubicExt[Fp4[Name]]
# QuadraticExt[Fp6[Name]]
# CubicExt[Fp4[Name]]
QuadraticExt[Fp6[Name]]

template c0*(a: ExtensionField): auto =
a.coords[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
./bindings/nvidia_abi {.all.},
./bindings/c_abi,
./llvm, ./ir,
./nvidia_inlineasm,
../primitives
constantine/platforms/llvm/bindings/nvidia_abi {.all.},
constantine/platforms/llvm/bindings/c_abi,
constantine/platforms/llvm/[llvm, nvidia_inlineasm],
constantine/platforms/primitives,
./ir

export
nvidia_abi, nvidia_inlineasm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
../platforms/code_generator/[llvm, nvidia, ir]
../platforms/llvm/llvm,
./ir, ./codegen_nvidia

# ############################################################
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import
constantine/math/config/[curves, precompute],
constantine/math/io/io_bigints,
../primitives, ../bithacks,
../../serialization/[endians, codecs, io_limbs],
./llvm
constantine/platforms/[primitives, bithacks],
constantine/platforms/llvm/llvm,
constantine/serialization/[endians, codecs, io_limbs]

# ############################################################
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GPU compilation targets

For CPUs, Constantine JIT-compiles the cryptographic kernels via LLVM.
For GPUs, Constantine JIT-compiles the cryptographic kernels via LLVM.

This allows targeting several devices with a single frontend, the LLVM IR.

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion constantine/platforms/metering/benchmarking.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# 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
from ../isa/cpudetect_x86 import cpuName_x86
from ../x86/cpudetect_x86 import cpuName_x86

const SupportsCPUName* = true
const SupportsGetTicks* = true
Expand Down
2 changes: 1 addition & 1 deletion constantine/platforms/primitives.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export
# This will impact benchmarks that do not need it, such as the threadpool.

when X86 and GCC_Compatible:
import isa/[cpudetect_x86, macro_assembler_x86]
import x86/[cpudetect_x86, macro_assembler_x86]
export cpudetect_x86, macro_assembler_x86

# No exceptions allowed in core cryptographic operations
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/gpu/hello_world_llvm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# * 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.

import constantine/platforms/code_generator/llvm
import constantine/platforms/llvm/llvm

echo "LLVM JIT compiler Hello World"

Expand Down
2 changes: 1 addition & 1 deletion tests/gpu/hello_world_nvidia.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# * 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.

import constantine/platforms/code_generator/[llvm, nvidia, bindings/c_abi]
import constantine/platforms/llvm/[llvm, nvidia, bindings/c_abi]

# ############################################################
#
Expand Down
22 changes: 11 additions & 11 deletions tests/gpu/t_nvidia_fp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import
# Standard library
std/[unittest, times],
# Internal
constantine/platforms/code_generator/[llvm, nvidia, ir],
constantine/platforms/llvm/llvm,
constantine/platforms/static_for,
constantine/named/algebras,
constantine/math/io/io_bigints,
constantine/math/arithmetic,
constantine/math_compiler/fields_nvidia,
constantine/math_compiler/[ir, impl_fields_nvidia, codegen_nvidia],
# Test utilities
helpers/prng_unsafe

Expand All @@ -28,14 +28,14 @@ echo "test_nvidia_fp xoshiro512** seed: ", seed

const Iters = 10

proc init(T: type CurveMetadata, asy: Assembler_LLVM, name: static Algebra, wordSize: WordSize): T =
proc init(T: type CurveMetadata, asy: Assembler_LLVM, curve: static Algebra, wordSize: WordSize): T =
CurveMetadata.init(
asy.ctx,
$name & "_", wordSize,
fpBits = uint32 Fp[name].bits(),
fpMod = Fp[name].getModulus().toHex(),
frBits = uint32 Fr[name].bits(),
frMod = Fr[name].getModulus().toHex())
$curve & "_", wordSize,
fpBits = uint32 Fp[curve].bits(),
fpMod = Fp[curve].getModulus().toHex(),
frBits = uint32 Fr[curve].bits(),
frMod = Fr[curve].getModulus().toHex())

proc genFieldAddPTX(asy: Assembler_LLVM, cm: CurveMetadata) =
let fpAdd = asy.field_add_gen(cm, fp)
Expand Down Expand Up @@ -67,7 +67,7 @@ var sm: tuple[major, minor: int32]
check cuDeviceGetAttribute(sm.major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, cudaDevice)
check cuDeviceGetAttribute(sm.minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cudaDevice)

proc t_field_add(name: static Algebra) =
proc t_field_add(curve: static Algebra) =
# Codegen
# -------------------------
let asy = Assembler_LLVM.new(bkNvidiaPTX, cstring("t_nvidia_" & $curve))
Expand Down Expand Up @@ -121,7 +121,7 @@ proc t_field_add(name: static Algebra) =
doAssert bool(rCPU == rGPU_32)
doAssert bool(rCPU == rGPU_64)

proc t_field_sub(name: static Algebra) =
proc t_field_sub(curve: static Algebra) =
# Codegen
# -------------------------
let asy = Assembler_LLVM.new(bkNvidiaPTX, cstring("t_nvidia_" & $curve))
Expand Down Expand Up @@ -175,7 +175,7 @@ proc t_field_sub(name: static Algebra) =
doAssert bool(rCPU == rGPU_32)
doAssert bool(rCPU == rGPU_64)

proc t_field_mul(name: static Algebra) =
proc t_field_mul(curve: static Algebra) =
# Codegen
# -------------------------
let asy = Assembler_LLVM.new(bkNvidiaPTX, cstring("t_nvidia_" & $curve))
Expand Down

0 comments on commit 21b072a

Please sign in to comment.