|
@@ -31,6 +31,7 @@
|
|
|
#include <cuda_runtime.h>
|
|
#include <cuda_runtime.h>
|
|
|
|
|
|
|
|
#include "atomic_iostream.h"
|
|
#include "atomic_iostream.h"
|
|
|
|
|
+#include "desired_resources.h"
|
|
|
#include "cudadl.h"
|
|
#include "cudadl.h"
|
|
|
|
|
|
|
|
NTL_CLIENT
|
|
NTL_CLIENT
|
|
@@ -113,7 +114,8 @@ bool dpcallback(void *cbdata, unsigned int *dpwords)
|
|
|
// label is "p" or "q", to be printed to report progress.
|
|
// label is "p" or "q", to be printed to report progress.
|
|
|
// Return 0 on failure, 1 on success.
|
|
// Return 0 on failure, 1 on success.
|
|
|
static int p_dl(const ZZ_p &target, const ZZ_p &base, ZZ &exp,
|
|
static int p_dl(const ZZ_p &target, const ZZ_p &base, ZZ &exp,
|
|
|
- const vec_ZZ &fvec, const string &label, unsigned int initial_subproblem_id)
|
|
|
|
|
|
|
+ const vec_ZZ &fvec, const string &label, unsigned int initial_subproblem_id,
|
|
|
|
|
+ unsigned short GB_mem)
|
|
|
{
|
|
{
|
|
|
const int flen = fvec.length();
|
|
const int flen = fvec.length();
|
|
|
|
|
|
|
@@ -130,6 +132,12 @@ static int p_dl(const ZZ_p &target, const ZZ_p &base, ZZ &exp,
|
|
|
curexp = 0;
|
|
curexp = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < flen; ++i) {
|
|
for (int i = 0; i < flen; ++i) {
|
|
|
|
|
+ unsigned short desired_dpnodes;
|
|
|
|
|
+ unsigned int max_workers;
|
|
|
|
|
+ unsigned int dpfreq;
|
|
|
|
|
+
|
|
|
|
|
+ desired_resources(fvec[i], 1, GB_mem, desired_dpnodes, max_workers, dpfreq);
|
|
|
|
|
+
|
|
|
ZZ quotient;
|
|
ZZ quotient;
|
|
|
ZZ_p subgroup_base;
|
|
ZZ_p subgroup_base;
|
|
|
ZZ_p subgroup_target;
|
|
ZZ_p subgroup_target;
|
|
@@ -137,6 +145,7 @@ static int p_dl(const ZZ_p &target, const ZZ_p &base, ZZ &exp,
|
|
|
{
|
|
{
|
|
|
AtomicWriter atomic_cout(cout);
|
|
AtomicWriter atomic_cout(cout);
|
|
|
atomic_cout << label << " submodulus " << i+1 << " of " << flen << "...\n";
|
|
atomic_cout << label << " submodulus " << i+1 << " of " << flen << "...\n";
|
|
|
|
|
+ atomic_cout << "Settings (memory, dpfreq): " << GB_mem << ", " << dpfreq << "\n";
|
|
|
// Figure out exp mod fvec[i] by taking each side to the power
|
|
// Figure out exp mod fvec[i] by taking each side to the power
|
|
|
// of phirho/fvec[i] so that we're working in the
|
|
// of phirho/fvec[i] so that we're working in the
|
|
|
// subgroup of order fvec[i].
|
|
// subgroup of order fvec[i].
|
|
@@ -163,10 +172,6 @@ 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;
|
|
|
- unsigned int dpfreq = 4294967; // 2^32/1000
|
|
|
|
|
- if (fvec[i] < 1000000) {
|
|
|
|
|
- dpfreq = 4294967295; // 2^32-1 : every point is a DP
|
|
|
|
|
- }
|
|
|
|
|
gettimeofday(&st, NULL);
|
|
gettimeofday(&st, NULL);
|
|
|
unsigned int launch_count = 0;
|
|
unsigned int launch_count = 0;
|
|
|
{
|
|
{
|
|
@@ -211,7 +216,9 @@ typedef struct {
|
|
|
|
|
|
|
|
// Behave like p_dl, but do the work in an asynchronous subprocess
|
|
// Behave like p_dl, but do the work in an asynchronous subprocess
|
|
|
static PDLHandle* p_dl_fork_start(const ZZ &p, const ZZ_p &target,
|
|
static PDLHandle* p_dl_fork_start(const ZZ &p, const ZZ_p &target,
|
|
|
- const ZZ_p &base, const vec_ZZ &fvec, const string &label, int deviceid, unsigned int initial_subproblem_id)
|
|
|
|
|
|
|
+ const ZZ_p &base, const vec_ZZ &fvec, const string &label,
|
|
|
|
|
+ int deviceid, unsigned int initial_subproblem_id,
|
|
|
|
|
+ unsigned short GB_mem_per_subprocess)
|
|
|
{
|
|
{
|
|
|
PDLHandle *handle = new PDLHandle;
|
|
PDLHandle *handle = new PDLHandle;
|
|
|
int fds[2];
|
|
int fds[2];
|
|
@@ -249,7 +256,7 @@ static PDLHandle* p_dl_fork_start(const ZZ &p, const ZZ_p &target,
|
|
|
AtomicWriter(cerr) << "Error setting CUDA device: " << cudaGetErrorString(cudares) << "\n";
|
|
AtomicWriter(cerr) << "Error setting CUDA device: " << cudaGetErrorString(cudares) << "\n";
|
|
|
exit(1);
|
|
exit(1);
|
|
|
}
|
|
}
|
|
|
- int res = p_dl(target_p, base_p, exp, fvec, label, initial_subproblem_id);
|
|
|
|
|
|
|
+ int res = p_dl(target_p, base_p, exp, fvec, label, initial_subproblem_id, GB_mem_per_subprocess);
|
|
|
|
|
|
|
|
if (res) {
|
|
if (res) {
|
|
|
// Write the result back to the parent using wfd
|
|
// Write the result back to the parent using wfd
|
|
@@ -301,6 +308,13 @@ static int p_dl_fork_join(PDLHandle *handle, ZZ &exp)
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
int main(int argc, char **argv)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (argc != 2) {
|
|
|
|
|
+ cerr << "Usage: " << argv[0] << " total_mem_GB";
|
|
|
|
|
+ exit(1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ unsigned short GB_mem_per_node = strtol(argv[1], NULL, 10);
|
|
|
|
|
+
|
|
|
// Initialize the prng with some randomness from the kernel
|
|
// Initialize the prng with some randomness from the kernel
|
|
|
unsigned char randbuf[1024];
|
|
unsigned char randbuf[1024];
|
|
|
ifstream urand("/dev/urandom");
|
|
ifstream urand("/dev/urandom");
|
|
@@ -337,8 +351,8 @@ int main(int argc, char **argv)
|
|
|
|
|
|
|
|
PDLHandle *handle_p, *handle_q;
|
|
PDLHandle *handle_p, *handle_q;
|
|
|
|
|
|
|
|
- handle_p = p_dl_fork_start(p, target, base, pfvec, "p", 0, 0);
|
|
|
|
|
- handle_q = p_dl_fork_start(q, target, base, qfvec, "q", 1, pfvec.length());
|
|
|
|
|
|
|
+ handle_p = p_dl_fork_start(p, target, base, pfvec, "p", 0, 0, GB_mem_per_node/2);
|
|
|
|
|
+ handle_q = p_dl_fork_start(q, target, base, qfvec, "q", 1, pfvec.length(), GB_mem_per_node/2);
|
|
|
res_p = p_dl_fork_join(handle_p, exp_p);
|
|
res_p = p_dl_fork_join(handle_p, exp_p);
|
|
|
res_q = p_dl_fork_join(handle_q, exp_q);
|
|
res_q = p_dl_fork_join(handle_q, exp_q);
|
|
|
|
|
|