|
@@ -24,6 +24,7 @@
|
|
|
#include <NTL/ZZ_p.h>
|
|
#include <NTL/ZZ_p.h>
|
|
|
|
|
|
|
|
#include <map>
|
|
#include <map>
|
|
|
|
|
+#include <sstream>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/types.h>
|
|
|
#include <sys/wait.h>
|
|
#include <sys/wait.h>
|
|
@@ -38,6 +39,10 @@ NTL_CLIENT
|
|
|
|
|
|
|
|
string output_prefix;
|
|
string output_prefix;
|
|
|
|
|
|
|
|
|
|
+#ifdef SAVE_DPS
|
|
|
|
|
+static ofstream dp_file_stream;
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
typedef map<std::string, pair<ZZ,ZZ> > DTable;
|
|
typedef map<std::string, pair<ZZ,ZZ> > DTable;
|
|
|
|
|
|
|
|
struct CBData {
|
|
struct CBData {
|
|
@@ -86,6 +91,15 @@ bool dpcallback(void *cbdata, unsigned int *dpwords)
|
|
|
pair<DTable::iterator, bool> res;
|
|
pair<DTable::iterator, bool> res;
|
|
|
string x((const char *)(dpwords+1), WORDS*sizeof(unsigned int));
|
|
string x((const char *)(dpwords+1), WORDS*sizeof(unsigned int));
|
|
|
|
|
|
|
|
|
|
+#ifdef SAVE_DPS
|
|
|
|
|
+ if (!d->found_collision) {
|
|
|
|
|
+ ZZ zz_x;
|
|
|
|
|
+ ZZFromBytes(zz_x, (const unsigned char *)(dpwords+1),
|
|
|
|
|
+ WORDS*sizeof(unsigned int));
|
|
|
|
|
+ dp_file_stream << zz_x << "\n";
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
res = d->dtable.insert(DTable::value_type(x, ab));
|
|
res = d->dtable.insert(DTable::value_type(x, ab));
|
|
|
if (!res.second) {
|
|
if (!res.second) {
|
|
|
// Collision!
|
|
// Collision!
|
|
@@ -165,6 +179,12 @@ static int p_dl(const ZZ_p &target, const ZZ_p &base, ZZ &exp,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#ifdef SAVE_DPS
|
|
|
|
|
+ std::ostringstream oss;
|
|
|
|
|
+ oss << "dplist_" << i+initial_subproblem_id << ".out";
|
|
|
|
|
+ dp_file_stream.open(oss.str().c_str());
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
// Now use your favourite method to get the DL of
|
|
// Now use your favourite method to get the DL of
|
|
|
// subgroup_target with base subgroup_base, knowing that it's in
|
|
// subgroup_target with base subgroup_base, knowing that it's in
|
|
|
// the range [0,fvec[i]).
|
|
// the range [0,fvec[i]).
|
|
@@ -172,8 +192,13 @@ static int p_dl(const ZZ_p &target, const ZZ_p &base, ZZ &exp,
|
|
|
ZZ md = ZZ_p::modulus();
|
|
ZZ md = ZZ_p::modulus();
|
|
|
CBData cbdata(subgroup_base, subgroup_target, fvec[i]);
|
|
CBData cbdata(subgroup_base, subgroup_target, fvec[i]);
|
|
|
struct timeval st, et;
|
|
struct timeval st, et;
|
|
|
|
|
+
|
|
|
|
|
+#ifdef SAVE_DPS
|
|
|
|
|
+ dp_file_stream << "Subproblem " << i+initial_subproblem_id << "\n";
|
|
|
|
|
+#endif
|
|
|
gettimeofday(&st, NULL);
|
|
gettimeofday(&st, NULL);
|
|
|
unsigned int launch_count = 0;
|
|
unsigned int launch_count = 0;
|
|
|
|
|
+ bool filled_dp_buffer = false;
|
|
|
{
|
|
{
|
|
|
#ifdef DERANDOMIZE
|
|
#ifdef DERANDOMIZE
|
|
|
RandomStreamPush push_seed;
|
|
RandomStreamPush push_seed;
|
|
@@ -181,7 +206,7 @@ static int p_dl(const ZZ_p &target, const ZZ_p &base, ZZ &exp,
|
|
|
// once we exit this scope
|
|
// once we exit this scope
|
|
|
SetSeed(rep(subgroup_base)*rep(subgroup_target)*fvec[i]*md);
|
|
SetSeed(rep(subgroup_base)*rep(subgroup_target)*fvec[i]*md);
|
|
|
#endif
|
|
#endif
|
|
|
- cuda_dl(subgroup_base, subgroup_target, fvec[i], md, dpfreq, &cbdata, &launch_count);
|
|
|
|
|
|
|
+ cuda_dl(subgroup_base, subgroup_target, fvec[i], md, dpfreq, &cbdata, &launch_count, &filled_dp_buffer);
|
|
|
}
|
|
}
|
|
|
ZZ subgroup_dl = cbdata.expon;
|
|
ZZ subgroup_dl = cbdata.expon;
|
|
|
gettimeofday(&et, NULL);
|
|
gettimeofday(&et, NULL);
|
|
@@ -199,6 +224,15 @@ static int p_dl(const ZZ_p &target, const ZZ_p &base, ZZ &exp,
|
|
|
// cout << "CRT\n";
|
|
// cout << "CRT\n";
|
|
|
// cout << "curexp = " << curexp << "\n";
|
|
// cout << "curexp = " << curexp << "\n";
|
|
|
// cout << "curmodulus = " << curmodulus << "\n\n";
|
|
// cout << "curmodulus = " << curmodulus << "\n\n";
|
|
|
|
|
+
|
|
|
|
|
+#ifdef SAVE_DPS
|
|
|
|
|
+ if (filled_dp_buffer) {
|
|
|
|
|
+ AtomicWriter atomic_cout(cout);
|
|
|
|
|
+ atomic_cout << "Warning: The device dp buffer was filled, so some points were not recorded.\n";
|
|
|
|
|
+ atomic_cout << "These points will not be reproducible (subproblem " << i+initial_subproblem_id << ").\n";
|
|
|
|
|
+ }
|
|
|
|
|
+ dp_file_stream.close();
|
|
|
|
|
+#endif
|
|
|
}
|
|
}
|
|
|
// We'd like a non-negative answer back
|
|
// We'd like a non-negative answer back
|
|
|
if (curexp >= 0) {
|
|
if (curexp >= 0) {
|
|
@@ -308,6 +342,13 @@ static int p_dl_fork_join(PDLHandle *handle, ZZ &exp)
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
int main(int argc, char **argv)
|
|
|
{
|
|
{
|
|
|
|
|
+#ifdef SAVE_DPS
|
|
|
|
|
+ cerr << "Note: Saving the distinguished points. Do not run huge problems or else it will use up all of your disk space.\n";
|
|
|
|
|
+#ifndef DERANDOMIZE
|
|
|
|
|
+ cerr << "Saving DPs without derandomization!\n";
|
|
|
|
|
+#endif
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
if (argc != 2) {
|
|
if (argc != 2) {
|
|
|
cerr << "Usage: " << argv[0] << " total_mem_GB";
|
|
cerr << "Usage: " << argv[0] << " total_mem_GB";
|
|
|
exit(1);
|
|
exit(1);
|