-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: generate uint32 arith only for babybear and koalabear #577
Conversation
Suggested edit: diff --git a/field/generator/options.go b/field/generator/options.go
index e89e8b1ad..71f7ee021 100644
--- a/field/generator/options.go
+++ b/field/generator/options.go
@@ -16,11 +16,11 @@ func (cfg *generatorConfig) HasFFT() bool {
}
func (cfg *generatorConfig) HasArm64() bool {
- return cfg.asmConfig != nil
+ return cfg.asmConfig != nil && cfg.asmConfig.BuildDir != ""
}
func (cfg *generatorConfig) HasAMD64() bool {
- return cfg.asmConfig != nil
+ return cfg.asmConfig != nil && cfg.asmConfig.BuildDir != ""
}
func WithFFT(cfg *config.FFT) Option {
@@ -38,7 +38,9 @@ func WithASM(cfg *config.Assembly) Option {
// default options
func generatorOptions(opts ...Option) generatorConfig {
// apply options
- opt := generatorConfig{}
+ opt := generatorConfig{
+ asmConfig: &config.Assembly{},
+ }
for _, option := range opts {
option(&opt)
}
|
Suggested edit: diff --git a/field/generator/generator_asm.go b/field/generator/generator_asm.go
index 8726ac7d7..a242433a3 100644
--- a/field/generator/generator_asm.go
+++ b/field/generator/generator_asm.go
@@ -28,7 +28,10 @@ func generateARM64(F *config.Field, asm *config.Assembly) (string, error) {
return "", nil
}
- os.MkdirAll(asm.BuildDir, 0755)
+ err := os.MkdirAll(asm.BuildDir, 0755)
+ if err != nil {
+ return "", fmt.Errorf("failed to create directory %s: %w", asm.BuildDir, err)
+ }
pathSrc := filepath.Join(asm.BuildDir, fmt.Sprintf(arm64.ElementASMFileName, F.NbWords))
hash, ok := mARM64.Load(pathSrc)
@@ -70,7 +73,10 @@ func generateAMD64(F *config.Field, asm *config.Assembly) (string, error) {
if !F.GenerateOpsAMD64 {
return "", nil
}
- os.MkdirAll(asm.BuildDir, 0755)
+ err := os.MkdirAll(asm.BuildDir, 0755)
+ if err != nil {
+ return "", fmt.Errorf("failed to create directory %s: %w", asm.BuildDir, err)
+ }
pathSrc := filepath.Join(asm.BuildDir, fmt.Sprintf(amd64.ElementASMFileName, F.NbWords))
hash, ok := mAMD64.Load(pathSrc)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks good. However, I'm still unable to compile the tinyfield in gnark.
In generator.go
I get panic as referencing to uninitialized config.Assembly
. I suggested edit to make asm generation more precise (have set outputdir). And when looking at code, also handle some more errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Now seems to work well with gnark.
To avoid breaking changes on caller side, small fields (< 31bits) will still generate uint64 arith for now.