Browse Source

BigArray in CBuild

master
Jordi Baylina 4 years ago
parent
commit
0e1a1bcc23
No known key found for this signature in database GPG Key ID: 7480C80C1BE43112
3 changed files with 15 additions and 8 deletions
  1. +13
    -6
      ports/c/builder.js
  2. +1
    -1
      src/build.js
  3. +1
    -1
      src/compiler.js

+ 13
- 6
ports/c/builder.js

@ -3,6 +3,7 @@ const utils = require("../../src/utils");
const assert = require("assert");
const Scalar = require("ffjavascript").Scalar;
const F1Field = require("ffjavascript").F1Field;
const BigArray = require("../../src/bigarray");
function ref2src(c) {
if ((c[0] == "R")||(c[0] == "RI")) {
@ -341,16 +342,17 @@ class FunctionBuilderC {
}
class BuilderC {
constructor(p) {
constructor(p, verbose) {
this.F = new F1Field(p);
this.hashMaps={};
this.componentEntriesTables={};
this.componentEntriesTables=new BigArray();
this.sizes ={};
this.constants = [];
this.functions = [];
this.components = [];
this.components = new BigArray();
this.usedConstants = {};
this.verbose = verbose;
}
setHeader(header) {
@ -363,7 +365,10 @@ class BuilderC {
}
addComponentEntriesTable(name, cet) {
this.componentEntriesTables[name] = cet;
this.componentEntriesTables.push({
name: name,
cet: cet
});
}
addSizes(name, accSizes) {
@ -444,8 +449,10 @@ class BuilderC {
_buildComponentEntriesTables(code) {
code.push("// Component Entry tables");
for (let cetName in this.componentEntriesTables) {
const cet = this.componentEntriesTables[cetName];
for (let i=0; i< this.componentEntriesTables.length; i++) {
if ((this.verbose)&&(i%100000 ==0)) console.log(`_buildComponentEntriesTables ${i}/${this.componentEntriesTables.length}`);
const cetName = this.componentEntriesTables[i].name;
const cet = this.componentEntriesTables[i].cet;
code.push(`Circom_ComponentEntry ${cetName}[${cet.length}] = {`);
for (let j=0; j<cet.length; j++) {

+ 1
- 1
src/build.js

@ -61,7 +61,7 @@ function buildEntryTables(ctx) {
const definedHashMaps = {};
for (let i=0; i<ctx.components.length; i++) {
if (ctx.verbose && (i%1000 ==0)) console.log(`buildEntryTables component: ${i}/${ctx.components.length}`);
if (ctx.verbose && (i%100000 ==0)) console.log(`buildEntryTables component: ${i}/${ctx.components.length}`);
const {htName, htMap} = addHashTable(i);
const componentEntriesTableName = ctx.getUniqueName("_entryTable" + ctx.components[i].template);

+ 1
- 1
src/compiler.js

@ -132,7 +132,7 @@ async function compile(srcFile, options) {
if (options.cSourceWriteStream) {
if (ctx.verbose) console.log("Generating c...");
measures.generateC = -performance.now();
ctx.builder = new BuilderC(options.prime);
ctx.builder = new BuilderC(options.prime, ctx.verbose);
build(ctx);
const rdStream = ctx.builder.build();
rdStream.pipe(options.cSourceWriteStream);

Loading…
Cancel
Save