Skip to content

Instantly share code, notes, and snippets.

View mratsim's full-sized avatar
:shipit:

Mamy Ratsimbazafy mratsim

:shipit:
  • Paris
View GitHub Profile
# 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.
# TODO: while there is likely no attacks available that may exploit
# how work is stolen from threads by other threads,
@mratsim
mratsim / c_openarray.nim
Created January 7, 2023 15:31
Dealing with push/pop and C openarray wrapper
# 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.
import std/macros
@mratsim
mratsim / bench_gmp_mul.nim
Created January 3, 2023 12:59
Constantine vs GMP on mul
# 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.
# This file should be put in a ./build subfolder of the constantine repo
# Compile with: nim c -r -d:danger build/bench_gmp_mul.nim
@mratsim
mratsim / mad.cu
Created December 17, 2022 09:33
Cuda 11.5 or lower muladd-carry bug
# https://forums.developer.nvidia.com/t/wrong-result-returned-by-madc-hi-u64-ptx-instruction-for-specific-operands/196094
# https://github.com/tickinbuaa/CudaTest
#include <cuda_runtime.h>
#include <memory>
__device__
inline void mac_with_carry(uint64_t &lo, uint64_t &hi, const uint64_t &a, const uint64_t &b, const uint64_t &c) {
if (blockIdx.x == 0 && threadIdx.x == 0) {
printf("GPU calculation input: a = %lx b = %lx c = %lx\n", a, b, c);
@mratsim
mratsim / llvm.nim
Created December 15, 2022 15:51
JIT compile Cuda kernel in Nim
# 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.
{.passc: gorge("llvm-config --cflags").}
{.passl: gorge("llvm-config --libs").}
@mratsim
mratsim / add_carry-cuda-nvptx64-nvidia-cuda-sm_86.ll
Created December 14, 2022 10:04
Uint256 on Nvidia, codegen quality investigation
; ModuleID = 'build/nvidia/add_carry.cu'
source_filename = "build/nvidia/add_carry.cu"
target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"
target triple = "nvptx64-nvidia-cuda"
%printf_args = type { i64 }
%printf_args.0 = type { i64 }
@.str = private unnamed_addr constant [27 x i8] c"32-bit Addition: %#016llx\0A\00", align 1
@.str1 = private unnamed_addr constant [27 x i8] c"64-bit Addition: %#016llx\0A\00", align 1
@mratsim
mratsim / llvm_bindings.nim
Created December 13, 2022 17:42
LLVM JIT for cryptography
# 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.
{.passc: gorge("llvm-config --cflags").}
{.passl: gorge("llvm-config --libs").}
# 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.
import
# Standard library
@mratsim
mratsim / 2020-03-12 Eth Impl Call 35.txt
Created March 12, 2020 14:37
2020-03-12 Eth Impl Call #35
https://github.com/ethereum/eth2.0-pm/issues/132
——————
Nimbus
PM:
- Created targets for March sprint
- Interop
- Starting auditing

0x1319645b02b60d36f9e3804a38e888fcfc13323c1eed57c2df6aa94910bc8f82