Skip to content
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

Gpu prover #141

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Extension of pack to const arguments
  • Loading branch information
rickb80 committed Dec 14, 2024

Unverified

This user has not yet uploaded their public signing key.
commit 390e0ea0e572530bebb2304345665729482677c1
6 changes: 3 additions & 3 deletions pil2-stark/src/goldilocks/src/goldilocks_base_field.hpp
Original file line number Diff line number Diff line change
@@ -256,10 +256,10 @@ static void store_avx512(Goldilocks::Element *a8, uint64_t stride_a, const __m51
#endif

/* Pack operations */
static void copy_pack( uint64_t nrowsPack, Element *dst, const Element *src);
static void copy_pack( uint64_t nrowsPack, Element *dst, uint64_t stride_dst, const Element *src);
static void copy_pack( uint64_t nrowsPack, Element *dst, const Element *src, bool const_src);
static void copy_pack( uint64_t nrowsPack, Element *dst, uint64_t stride_dst, const Element *src, bool const_src);
static void copy_pack( uint64_t nrowsPack, Element *dst, const Element *src, uint64_t stride_src);
static void op_pack( uint64_t nrowsPack, uint64_t op, Element *c, const Element *a, const Element *b);
static void op_pack( uint64_t nrowsPack, uint64_t op, Element *c, const Element *a, bool const_a, const Element *b, bool const_b);

};

135 changes: 123 additions & 12 deletions pil2-stark/src/goldilocks/src/goldilocks_base_field_pack.hpp
Original file line number Diff line number Diff line change
@@ -2,34 +2,50 @@
#define GOLDILOCKS_PACK
#include "goldilocks_base_field.hpp"
#include <cassert>

/*
Implementations for expressions:
*/

inline void Goldilocks::copy_pack( uint64_t nrowsPack, Element *dst, const Element *src){
for (uint64_t i = 0; i < nrowsPack; ++i)
{

inline void Goldilocks::copy_pack(uint64_t nrowsPack, Element *dst, const Element *src, bool const_src) {
if (const_src) {
for (uint64_t i = 0; i < nrowsPack; ++i) {
dst[i].fe = src[0].fe;
}
} else {
for (uint64_t i = 0; i < nrowsPack; ++i) {
dst[i].fe = src[i].fe;
}
}
}


inline void Goldilocks::copy_pack( uint64_t nrowsPack, Element *dst, uint64_t stride_dst, const Element *src){
inline void Goldilocks::copy_pack( uint64_t nrowsPack, Element *dst, uint64_t stride_dst, const Element *src, bool const_src){

if(const_src){
for (uint64_t i = 0; i < nrowsPack; ++i)
{
dst[i*stride_dst].fe = src[i].fe;
dst[i*stride_dst].fe = src[0].fe;
}
}

inline void Goldilocks::copy_pack( uint64_t nrowsPack, Element *dst, const Element *src, uint64_t stride_src){
} else{
for (uint64_t i = 0; i < nrowsPack; ++i)
{
dst[i].fe = src[i*stride_src].fe;
dst[i*stride_dst].fe = src[i].fe;
}
}

inline void Goldilocks::op_pack( uint64_t nrowsPack, uint64_t op, Element *c, const Element *a, const Element *b){
}

inline void Goldilocks::copy_pack( uint64_t nrowsPack, Element *dst, const Element *src, uint64_t stride_src){

for (uint64_t i = 0; i < nrowsPack; ++i)
{
dst[i].fe = src[i*stride_src].fe;
}
}

inline void Goldilocks::op_pack( uint64_t nrowsPack, uint64_t op, Element *c, const Element *a, bool const_a, const Element *b, bool const_b){

if( !const_a & !const_b){
switch (op)
{
case 0:
@@ -60,6 +76,101 @@
assert(0);
break;
}
} else if( !const_a & const_b){
switch (op)
{
case 0:
for (uint64_t i = 0; i < nrowsPack; ++i)
{
add(c[i], a[i], b[0]);
}
break;
case 1:
for (uint64_t i = 0; i < nrowsPack; ++i)
{
sub(c[i], a[i], b[0]);
}
break;
case 2:
for (uint64_t i = 0; i < nrowsPack; ++i)
{
mul(c[i], a[i], b[0]);
}
break;
case 3:
for (uint64_t i = 0; i < nrowsPack; ++i)
{
sub(c[i], b[0], a[i]);
}
break;
default:
assert(0);
break;
}
} else if( const_a & !const_b){
switch (op)
{
case 0:
for (uint64_t i = 0; i < nrowsPack; ++i)
{
add(c[i], a[0], b[i]);
}
break;
case 1:
for (uint64_t i = 0; i < nrowsPack; ++i)
{
sub(c[i], a[0], b[i]);
}
break;
case
2:
for (uint64_t i = 0; i < nrowsPack; ++i)
{
mul(c[i], a[0], b[i]);
}
break;
case 3:
for (uint64_t i = 0; i < nrowsPack; ++i)
{
sub(c[i], b[i], a[0]);
}
break;
default:
assert(0);
break;
}
} else{
switch (op)
{
case 0:
for (uint64_t i = 0; i < nrowsPack; ++i)
{
add(c[i], a[0], b[0]);
}
break;
case 1:
for (uint64_t i = 0; i < nrowsPack; ++i)
{
sub(c[i], a[0], b[0]);
}
break;
case 2:
for (uint64_t i = 0; i < nrowsPack; ++i)
{
mul(c[i], a[0], b[0]);
}
break;
case 3:
for (uint64_t i = 0; i < nrowsPack; ++i)
{
sub(c[i], b[0], a[0]);
}
break;
default:
assert(0);
break;
}
}
}

#endif
14 changes: 7 additions & 7 deletions pil2-stark/src/goldilocks/src/goldilocks_cubic_extension.hpp
Original file line number Diff line number Diff line change
@@ -321,14 +321,14 @@ class Goldilocks3

/* Pack operations */

static void copy_pack( uint64_t nrowsPack, Goldilocks::Element *c_, const Goldilocks::Element *a_);
static void add_pack( uint64_t nrowsPack, Goldilocks::Element *c_, const Goldilocks::Element *a_, const Goldilocks::Element *b_);
static void sub_pack( uint64_t nrowsPack, Goldilocks::Element *c_, const Goldilocks::Element *a_, const Goldilocks::Element *b_);
static void mul_pack(uint64_t nrowsPack, Goldilocks::Element *c_, const Goldilocks::Element *a_, const Goldilocks::Element *b_);
static void mul_pack(uint64_t nrowsPack, Goldilocks::Element *c_, const Goldilocks::Element *a_, const Goldilocks::Element *challenge_, const Goldilocks::Element *challenge_ops_);
static void copy_pack( uint64_t nrowsPack, Goldilocks::Element *c_, const Goldilocks::Element *a_, bool const_a);
static void add_pack( uint64_t nrowsPack, Goldilocks::Element *c_, const Goldilocks::Element *a_, bool const_a, const Goldilocks::Element *b_, bool const_b);
static void sub_pack( uint64_t nrowsPack, Goldilocks::Element *c_, const Goldilocks::Element *a_, bool const_a, const Goldilocks::Element *b_, bool cont_b);
static void mul_pack(uint64_t nrowsPack, Goldilocks::Element *c_, const Goldilocks::Element *a_, bool const_a, const Goldilocks::Element *b_, bool const_b);
static void mul_pack(uint64_t nrowsPack, Goldilocks::Element *c_, const Goldilocks::Element *a_, bool const_a, const Goldilocks::Element *challenge_, const Goldilocks::Element *challenge_ops_);

static void op_pack( uint64_t nrowsPack, uint64_t op, Goldilocks::Element *c, const Goldilocks::Element *a, const Goldilocks::Element *b);
static void op_31_pack( uint64_t nrowsPack, uint64_t op, Goldilocks::Element *c, const Goldilocks::Element *a, const Goldilocks::Element *b);
static void op_pack( uint64_t nrowsPack, uint64_t op, Goldilocks::Element *c, const Goldilocks::Element *a, bool const_a, const Goldilocks::Element *b, bool const_b);
static void op_31_pack( uint64_t nrowsPack, uint64_t op, Goldilocks::Element *c, const Goldilocks::Element *a, bool const_a, const Goldilocks::Element *b, bool const_b);

/* AVX operations */
static void copy_avx(Element_avx c_, const Element_avx a_);
Loading