Skip to content

Commit

Permalink
chore(avm): better log_derivative_inverse_round (#7360)
Browse files Browse the repository at this point in the history
Moved it to the prover cpp and used metaprogramming to cycle through relations.

I'm expecting the compiler to be smart enough to remove recursion. I think this is quite common in metaprogramming.
  • Loading branch information
fcarreiro authored Jul 8, 2024
1 parent 7d8c833 commit 6329833
Show file tree
Hide file tree
Showing 60 changed files with 314 additions and 837 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@

namespace bb {

/**
* @brief This class contains an example of how to set LookupSettings classes used by the
* GenericLookupRelationImpl class to specify a scaled lookup
*
* @details To create your own lookup:
* 1) Create a copy of this class and rename it
* 2) Update all the values with the ones needed for your lookup
* 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to
* include the new settings
* 4) Add the relation with the chosen settings to Relations in the flavor (for example,"`
* using Relations = std::tuple<GenericLookupRelation<ExampleXorLookupSettings,
* FF>>;)`
*
*/
class incl_main_tag_err_lookup_settings {
public:
static constexpr size_t READ_TERMS = 1;
Expand Down Expand Up @@ -68,7 +54,10 @@ class incl_main_tag_err_lookup_settings {
};

template <typename FF_>
using incl_main_tag_err_relation = GenericLookupRelation<incl_main_tag_err_lookup_settings, FF_>;
class incl_main_tag_err_relation : public GenericLookupRelation<incl_main_tag_err_lookup_settings, FF_> {
public:
static constexpr const char* NAME = "incl_main_tag_err";
};
template <typename FF_> using incl_main_tag_err = GenericLookup<incl_main_tag_err_lookup_settings, FF_>;

} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@

namespace bb {

/**
* @brief This class contains an example of how to set LookupSettings classes used by the
* GenericLookupRelationImpl class to specify a scaled lookup
*
* @details To create your own lookup:
* 1) Create a copy of this class and rename it
* 2) Update all the values with the ones needed for your lookup
* 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to
* include the new settings
* 4) Add the relation with the chosen settings to Relations in the flavor (for example,"`
* using Relations = std::tuple<GenericLookupRelation<ExampleXorLookupSettings,
* FF>>;)`
*
*/
class incl_mem_tag_err_lookup_settings {
public:
static constexpr size_t READ_TERMS = 1;
Expand Down Expand Up @@ -59,7 +45,11 @@ class incl_mem_tag_err_lookup_settings {
}
};

template <typename FF_> using incl_mem_tag_err_relation = GenericLookupRelation<incl_mem_tag_err_lookup_settings, FF_>;
template <typename FF_>
class incl_mem_tag_err_relation : public GenericLookupRelation<incl_mem_tag_err_lookup_settings, FF_> {
public:
static constexpr const char* NAME = "incl_mem_tag_err";
};
template <typename FF_> using incl_mem_tag_err = GenericLookup<incl_mem_tag_err_lookup_settings, FF_>;

} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@

namespace bb {

/**
* @brief This class contains an example of how to set LookupSettings classes used by the
* GenericLookupRelationImpl class to specify a scaled lookup
*
* @details To create your own lookup:
* 1) Create a copy of this class and rename it
* 2) Update all the values with the ones needed for your lookup
* 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to
* include the new settings
* 4) Add the relation with the chosen settings to Relations in the flavor (for example,"`
* using Relations = std::tuple<GenericLookupRelation<ExampleXorLookupSettings,
* FF>>;)`
*
*/
class kernel_output_lookup_lookup_settings {
public:
static constexpr size_t READ_TERMS = 1;
Expand Down Expand Up @@ -80,7 +66,10 @@ class kernel_output_lookup_lookup_settings {
};

template <typename FF_>
using kernel_output_lookup_relation = GenericLookupRelation<kernel_output_lookup_lookup_settings, FF_>;
class kernel_output_lookup_relation : public GenericLookupRelation<kernel_output_lookup_lookup_settings, FF_> {
public:
static constexpr const char* NAME = "kernel_output_lookup";
};
template <typename FF_> using kernel_output_lookup = GenericLookup<kernel_output_lookup_lookup_settings, FF_>;

} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@

namespace bb {

/**
* @brief This class contains an example of how to set LookupSettings classes used by the
* GenericLookupRelationImpl class to specify a scaled lookup
*
* @details To create your own lookup:
* 1) Create a copy of this class and rename it
* 2) Update all the values with the ones needed for your lookup
* 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to
* include the new settings
* 4) Add the relation with the chosen settings to Relations in the flavor (for example,"`
* using Relations = std::tuple<GenericLookupRelation<ExampleXorLookupSettings,
* FF>>;)`
*
*/
class lookup_byte_lengths_lookup_settings {
public:
static constexpr size_t READ_TERMS = 1;
Expand Down Expand Up @@ -72,7 +58,10 @@ class lookup_byte_lengths_lookup_settings {
};

template <typename FF_>
using lookup_byte_lengths_relation = GenericLookupRelation<lookup_byte_lengths_lookup_settings, FF_>;
class lookup_byte_lengths_relation : public GenericLookupRelation<lookup_byte_lengths_lookup_settings, FF_> {
public:
static constexpr const char* NAME = "lookup_byte_lengths";
};
template <typename FF_> using lookup_byte_lengths = GenericLookup<lookup_byte_lengths_lookup_settings, FF_>;

} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@

namespace bb {

/**
* @brief This class contains an example of how to set LookupSettings classes used by the
* GenericLookupRelationImpl class to specify a scaled lookup
*
* @details To create your own lookup:
* 1) Create a copy of this class and rename it
* 2) Update all the values with the ones needed for your lookup
* 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to
* include the new settings
* 4) Add the relation with the chosen settings to Relations in the flavor (for example,"`
* using Relations = std::tuple<GenericLookupRelation<ExampleXorLookupSettings,
* FF>>;)`
*
*/
class lookup_byte_operations_lookup_settings {
public:
static constexpr size_t READ_TERMS = 1;
Expand Down Expand Up @@ -80,7 +66,10 @@ class lookup_byte_operations_lookup_settings {
};

template <typename FF_>
using lookup_byte_operations_relation = GenericLookupRelation<lookup_byte_operations_lookup_settings, FF_>;
class lookup_byte_operations_relation : public GenericLookupRelation<lookup_byte_operations_lookup_settings, FF_> {
public:
static constexpr const char* NAME = "lookup_byte_operations";
};
template <typename FF_> using lookup_byte_operations = GenericLookup<lookup_byte_operations_lookup_settings, FF_>;

} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@

namespace bb {

/**
* @brief This class contains an example of how to set LookupSettings classes used by the
* GenericLookupRelationImpl class to specify a scaled lookup
*
* @details To create your own lookup:
* 1) Create a copy of this class and rename it
* 2) Update all the values with the ones needed for your lookup
* 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to
* include the new settings
* 4) Add the relation with the chosen settings to Relations in the flavor (for example,"`
* using Relations = std::tuple<GenericLookupRelation<ExampleXorLookupSettings,
* FF>>;)`
*
*/
class lookup_div_u16_0_lookup_settings {
public:
static constexpr size_t READ_TERMS = 1;
Expand Down Expand Up @@ -67,7 +53,11 @@ class lookup_div_u16_0_lookup_settings {
}
};

template <typename FF_> using lookup_div_u16_0_relation = GenericLookupRelation<lookup_div_u16_0_lookup_settings, FF_>;
template <typename FF_>
class lookup_div_u16_0_relation : public GenericLookupRelation<lookup_div_u16_0_lookup_settings, FF_> {
public:
static constexpr const char* NAME = "lookup_div_u16_0";
};
template <typename FF_> using lookup_div_u16_0 = GenericLookup<lookup_div_u16_0_lookup_settings, FF_>;

} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@

namespace bb {

/**
* @brief This class contains an example of how to set LookupSettings classes used by the
* GenericLookupRelationImpl class to specify a scaled lookup
*
* @details To create your own lookup:
* 1) Create a copy of this class and rename it
* 2) Update all the values with the ones needed for your lookup
* 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to
* include the new settings
* 4) Add the relation with the chosen settings to Relations in the flavor (for example,"`
* using Relations = std::tuple<GenericLookupRelation<ExampleXorLookupSettings,
* FF>>;)`
*
*/
class lookup_div_u16_1_lookup_settings {
public:
static constexpr size_t READ_TERMS = 1;
Expand Down Expand Up @@ -67,7 +53,11 @@ class lookup_div_u16_1_lookup_settings {
}
};

template <typename FF_> using lookup_div_u16_1_relation = GenericLookupRelation<lookup_div_u16_1_lookup_settings, FF_>;
template <typename FF_>
class lookup_div_u16_1_relation : public GenericLookupRelation<lookup_div_u16_1_lookup_settings, FF_> {
public:
static constexpr const char* NAME = "lookup_div_u16_1";
};
template <typename FF_> using lookup_div_u16_1 = GenericLookup<lookup_div_u16_1_lookup_settings, FF_>;

} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@

namespace bb {

/**
* @brief This class contains an example of how to set LookupSettings classes used by the
* GenericLookupRelationImpl class to specify a scaled lookup
*
* @details To create your own lookup:
* 1) Create a copy of this class and rename it
* 2) Update all the values with the ones needed for your lookup
* 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to
* include the new settings
* 4) Add the relation with the chosen settings to Relations in the flavor (for example,"`
* using Relations = std::tuple<GenericLookupRelation<ExampleXorLookupSettings,
* FF>>;)`
*
*/
class lookup_div_u16_2_lookup_settings {
public:
static constexpr size_t READ_TERMS = 1;
Expand Down Expand Up @@ -67,7 +53,11 @@ class lookup_div_u16_2_lookup_settings {
}
};

template <typename FF_> using lookup_div_u16_2_relation = GenericLookupRelation<lookup_div_u16_2_lookup_settings, FF_>;
template <typename FF_>
class lookup_div_u16_2_relation : public GenericLookupRelation<lookup_div_u16_2_lookup_settings, FF_> {
public:
static constexpr const char* NAME = "lookup_div_u16_2";
};
template <typename FF_> using lookup_div_u16_2 = GenericLookup<lookup_div_u16_2_lookup_settings, FF_>;

} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@

namespace bb {

/**
* @brief This class contains an example of how to set LookupSettings classes used by the
* GenericLookupRelationImpl class to specify a scaled lookup
*
* @details To create your own lookup:
* 1) Create a copy of this class and rename it
* 2) Update all the values with the ones needed for your lookup
* 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to
* include the new settings
* 4) Add the relation with the chosen settings to Relations in the flavor (for example,"`
* using Relations = std::tuple<GenericLookupRelation<ExampleXorLookupSettings,
* FF>>;)`
*
*/
class lookup_div_u16_3_lookup_settings {
public:
static constexpr size_t READ_TERMS = 1;
Expand Down Expand Up @@ -67,7 +53,11 @@ class lookup_div_u16_3_lookup_settings {
}
};

template <typename FF_> using lookup_div_u16_3_relation = GenericLookupRelation<lookup_div_u16_3_lookup_settings, FF_>;
template <typename FF_>
class lookup_div_u16_3_relation : public GenericLookupRelation<lookup_div_u16_3_lookup_settings, FF_> {
public:
static constexpr const char* NAME = "lookup_div_u16_3";
};
template <typename FF_> using lookup_div_u16_3 = GenericLookup<lookup_div_u16_3_lookup_settings, FF_>;

} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@

namespace bb {

/**
* @brief This class contains an example of how to set LookupSettings classes used by the
* GenericLookupRelationImpl class to specify a scaled lookup
*
* @details To create your own lookup:
* 1) Create a copy of this class and rename it
* 2) Update all the values with the ones needed for your lookup
* 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to
* include the new settings
* 4) Add the relation with the chosen settings to Relations in the flavor (for example,"`
* using Relations = std::tuple<GenericLookupRelation<ExampleXorLookupSettings,
* FF>>;)`
*
*/
class lookup_div_u16_4_lookup_settings {
public:
static constexpr size_t READ_TERMS = 1;
Expand Down Expand Up @@ -67,7 +53,11 @@ class lookup_div_u16_4_lookup_settings {
}
};

template <typename FF_> using lookup_div_u16_4_relation = GenericLookupRelation<lookup_div_u16_4_lookup_settings, FF_>;
template <typename FF_>
class lookup_div_u16_4_relation : public GenericLookupRelation<lookup_div_u16_4_lookup_settings, FF_> {
public:
static constexpr const char* NAME = "lookup_div_u16_4";
};
template <typename FF_> using lookup_div_u16_4 = GenericLookup<lookup_div_u16_4_lookup_settings, FF_>;

} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@

namespace bb {

/**
* @brief This class contains an example of how to set LookupSettings classes used by the
* GenericLookupRelationImpl class to specify a scaled lookup
*
* @details To create your own lookup:
* 1) Create a copy of this class and rename it
* 2) Update all the values with the ones needed for your lookup
* 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to
* include the new settings
* 4) Add the relation with the chosen settings to Relations in the flavor (for example,"`
* using Relations = std::tuple<GenericLookupRelation<ExampleXorLookupSettings,
* FF>>;)`
*
*/
class lookup_div_u16_5_lookup_settings {
public:
static constexpr size_t READ_TERMS = 1;
Expand Down Expand Up @@ -67,7 +53,11 @@ class lookup_div_u16_5_lookup_settings {
}
};

template <typename FF_> using lookup_div_u16_5_relation = GenericLookupRelation<lookup_div_u16_5_lookup_settings, FF_>;
template <typename FF_>
class lookup_div_u16_5_relation : public GenericLookupRelation<lookup_div_u16_5_lookup_settings, FF_> {
public:
static constexpr const char* NAME = "lookup_div_u16_5";
};
template <typename FF_> using lookup_div_u16_5 = GenericLookup<lookup_div_u16_5_lookup_settings, FF_>;

} // namespace bb
Loading

0 comments on commit 6329833

Please sign in to comment.