-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a8191b
commit ab69139
Showing
88 changed files
with
25,529 additions
and
499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ | |
*.cubin | ||
*.bin | ||
*.fatbin | ||
*.so | ||
*.nsys-rep | ||
*.ncu-rep | ||
**/target | ||
**/.vscode | ||
**/.*lock*csv# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CUDA_ROOT_DIR = /usr/local/cuda | ||
NVCC = $(CUDA_ROOT_DIR)/bin/nvcc | ||
CFLAGS = -Xcompiler -fPIC -std=c++17 | ||
LDFLAGS = -shared | ||
FEATURES = -DG2_DEFINED | ||
|
||
TARGET_BN254 = libbn254.so | ||
TARGET_BLS12_381 = libbls12_381.so | ||
TARGET_BLS12_377 = libbls12_377.so | ||
|
||
VPATH = ../icicle/curves/bn254:../icicle/curves/bls12_377:../icicle/curves/bls12_381 | ||
|
||
SRCS_BN254 = lde.cu msm.cu projective.cu ve_mod_mult.cu | ||
SRCS_BLS12_381 = lde.cu msm.cu projective.cu ve_mod_mult.cu poseidon.cu | ||
SRCS_BLS12_377 = lde.cu msm.cu projective.cu ve_mod_mult.cu | ||
|
||
all: $(TARGET_BN254) $(TARGET_BLS12_381) $(TARGET_BLS12_377) | ||
|
||
$(TARGET_BN254): | ||
$(NVCC) $(FEATURES) $(CFLAGS) $(LDFLAGS) $(addprefix ../icicle/curves/bn254/, $(SRCS_BN254)) -o $@ | ||
|
||
$(TARGET_BLS12_381): | ||
$(NVCC) $(FEATURES) $(CFLAGS) $(LDFLAGS) $(addprefix ../icicle/curves/bls12_381/, $(SRCS_BLS12_381)) -o $@ | ||
|
||
$(TARGET_BLS12_377): | ||
$(NVCC) $(FEATURES) $(CFLAGS) $(LDFLAGS) $(addprefix ../icicle/curves/bls12_377/, $(SRCS_BLS12_377)) -o $@ | ||
|
||
clean: | ||
rm -f $(TARGET_BN254) $(TARGET_BLS12_381) $(TARGET_BLS12_377) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# ICICLE CUDA to Golang Binding Guide | ||
|
||
This guide provides instructions on how to compile CUDA code using the provided Makefile, and then how to use the resulting shared libraries to bind Golang to ICICLE's CUDA code. | ||
|
||
## Prerequisites | ||
|
||
To compile the CUDA files, you will need: | ||
|
||
- CUDA toolkit installed. The Makefile assumes CUDA is installed in `/usr/local/cuda`. If CUDA is installed in a different location, please adjust the `CUDA_ROOT_DIR` variable accordingly. | ||
- A compatible GPU and corresponding driver installed on your machine. | ||
|
||
## Structure of the Makefile | ||
|
||
The Makefile is designed to compile CUDA files for three curves: BN254, BLS12_381, and BLS12_377. The source files are located in the `icicle/curves/` directory. | ||
|
||
## Compiling CUDA Code | ||
|
||
1. Navigate to the directory containing the Makefile in your terminal. | ||
2. To compile all curve libraries, use the `make all` command. This will create three shared libraries: `libbn254.so`, `libbls12_381.so`, and `libbls12_377.so`. | ||
3. If you want to compile a specific curve, you can do so by specifying the target. For example, to compile only the BN254 curve, use `make libbn254.so`. Replace `libbn254.so` with `libbls12_381.so` or `libbls12_377.so` to compile those curves instead. | ||
|
||
The resulting `.so` files are the compiled shared libraries for each curve. | ||
|
||
## Golang Binding | ||
|
||
The shared libraries produced from the CUDA code compilation are used to bind Golang to ICICLE's CUDA code. | ||
|
||
1. These shared libraries (`libbn254.so`, `libbls12_381.so`, `libbls12_377.so`) can be imported in your Go project to leverage the GPU accelerated functionalities provided by ICICLE. | ||
|
||
2. In your Go project, you can use `cgo` to link these shared libraries. Here's a basic example on how you can use `cgo` to link these libraries: | ||
|
||
```go | ||
/* | ||
#cgo LDFLAGS: -L/path/to/shared/libs -lbn254 -lbls12_381 -lbls12_377 | ||
#include "icicle.h" // make sure you use the correct header file(s) | ||
*/ | ||
import "C" | ||
|
||
func main() { | ||
// Now you can call the C functions from the ICICLE libraries. | ||
// Note that C function calls are prefixed with 'C.' in Go code. | ||
} | ||
``` | ||
|
||
Replace `/path/to/shared/libs` with the actual path where the shared libraries are located on your system. | ||
|
||
## Cleaning up | ||
|
||
If you want to remove the compiled files, you can use the `make clean` command. This will remove the `libbn254.so`, `libbls12_381.so`, and `libbls12_377.so` files. |
Oops, something went wrong.