Advertisement
Guest User

Untitled

a guest
Sep 28th, 2017
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.09 KB | None | 0 0
  1. Index: pform/pfgw/bench.cpp
  2. ===================================================================
  3. --- pform/pfgw/bench.cpp (revision 643)
  4. +++ pform/pfgw/bench.cpp (working copy)
  5. @@ -121,6 +121,7 @@
  6. Integer *pResult=ex_evaluate(pTestContext,expr);
  7.  
  8. gwinit2(&gwdata, sizeof(gwhandle), (char *) GWNUM_VERSION);
  9. + gwset_num_threads(&gwdata, g_Nthreads);
  10.  
  11. if (CreateModulus(pResult, g_cpTestString, true)) return false;
  12.  
  13. @@ -353,7 +354,9 @@
  14. else if (n > 1000) n = n - (n % 1000);
  15. else if (n > 100) n = n - (n % 100);
  16.  
  17. - gwmap_to_fft_info(&gwdata, k, b, 90, c);
  18. + gwinit(&gwdata);
  19. + gwset_num_threads(&gwdata, g_Nthreads);
  20. + gwinfo(&gwdata, k, b, 90, c);
  21.  
  22. gwfft_description (&gwdata, last_fftlen);
  23.  
  24. @@ -361,7 +364,9 @@
  25. {
  26. if (g_bExitNow) break;
  27.  
  28. - if (gwmap_to_fft_info(&gwdata, k, b, n, c) > 1) break;
  29. + gwinit(&gwdata);
  30. + gwset_num_threads(&gwdata, g_Nthreads);
  31. + if (gwinfo(&gwdata, k, b, n, c) > 1) break;
  32.  
  33. gwfft_description (&gwdata, next_fftlen);
  34.  
  35. Index: pform/pfgw/gf_factorize.cpp
  36. ===================================================================
  37. --- pform/pfgw/gf_factorize.cpp (revision 643)
  38. +++ pform/pfgw/gf_factorize.cpp (working copy)
  39. @@ -235,6 +235,7 @@
  40. Timer.Start();
  41.  
  42. gwinit2(&gwdata, sizeof(gwhandle), (char *) GWNUM_VERSION);
  43. + gwset_num_threads(&gwdata, g_Nthreads);
  44. gwsetmaxmulbyconst(&gwdata, base); // maximum multiplier
  45.  
  46. if (CreateModulus(N, g_cpTestString, true, fftSize)) return 0;
  47. Index: pform/pfgw/gfn_prp.cpp
  48. ===================================================================
  49. --- pform/pfgw/gfn_prp.cpp (revision 643)
  50. +++ pform/pfgw/gfn_prp.cpp (working copy)
  51. @@ -70,6 +70,7 @@
  52. {
  53. // create a context
  54. gwinit2(&gwdata, sizeof(gwhandle), (char *) GWNUM_VERSION);
  55. + gwset_num_threads(&gwdata, g_Nthreads);
  56. gwsetmaxmulbyconst(&gwdata, iBase); // maximum multiplier
  57. if (CreateModulus(1.0,base,_exp,1)) return FALSE;
  58.  
  59. @@ -81,6 +82,7 @@
  60. fftSize++;
  61.  
  62. gwinit2(&gwdata, sizeof(gwhandle), (char *) GWNUM_VERSION);
  63. + gwset_num_threads(&gwdata, g_Nthreads);
  64. gwsetmaxmulbyconst(&gwdata, iBase); // maximum multiplier
  65.  
  66. if (CreateModulus(1.0, base, _exp, 1, fftSize)) return false;
  67. Index: pform/pfgw/gw_gapper.cpp
  68. ===================================================================
  69. --- pform/pfgw/gw_gapper.cpp (revision 643)
  70. +++ pform/pfgw/gw_gapper.cpp (working copy)
  71. @@ -76,6 +76,7 @@
  72.  
  73. // create a context
  74. gwinit2(&gwdata, sizeof(gwhandle), GWNUM_VERSION);
  75. + gwset_num_threads(&gwdata, g_Nthreads);
  76.  
  77. gwsetmaxmulbyconst(&gwdata, iBase); // maximum multiplier
  78. if (CreateModulus(N, g_cpTestString)) return false;
  79. Index: pform/pfgw/gw_prp.cpp
  80. ===================================================================
  81. --- pform/pfgw/gw_prp.cpp (revision 643)
  82. +++ pform/pfgw/gw_prp.cpp (working copy)
  83. @@ -88,6 +88,7 @@
  84. fftSize++;
  85.  
  86. gwinit2(&gwdata, sizeof(gwhandle), (char *) GWNUM_VERSION);
  87. + gwset_num_threads(&gwdata, g_Nthreads);
  88. gwsetmaxmulbyconst(&gwdata, iBase); // maximum multiplier
  89.  
  90. if (CreateModulus(N, g_cpTestString, true, fftSize)) return -2;
  91. @@ -112,7 +113,7 @@
  92.  
  93. // create a context
  94. gwinit2(&gwdata, sizeof(gwhandle), (char *) GWNUM_VERSION);
  95. -
  96. + gwset_num_threads(&gwdata, g_Nthreads);
  97. testN = *N;
  98. gwsetmaxmulbyconst(&gwdata, iBase); // maximum multiplier
  99. if (CreateModulus(N, g_cpTestString, true)) return;
  100. Index: pform/pfgw/pfgw_globals.h
  101. ===================================================================
  102. --- pform/pfgw/pfgw_globals.h (revision 643)
  103. +++ pform/pfgw/pfgw_globals.h (working copy)
  104. @@ -3,6 +3,7 @@
  105.  
  106. extern int iBase;
  107. extern int g_nIterationCnt;
  108. +extern int g_Nthreads;
  109. extern bool volatile g_bExitNow;
  110. extern bool volatile g_bExited;
  111. extern unsigned long clocks_per_sec; // Machine dependent
  112. Index: pform/pfgw/pfgw_main.cpp
  113. ===================================================================
  114. --- pform/pfgw/pfgw_main.cpp (revision 643)
  115. +++ pform/pfgw/pfgw_main.cpp (working copy)
  116. @@ -46,6 +46,7 @@
  117. PFIni *g_pIni;
  118. int g_nIterationCnt=2500;
  119. int g_CompositeAthenticationLevel = 0; // valid values are 0, 1, 2, 3, 4, 5
  120. +int g_Nthreads = 1;
  121. int g_ExtraSQFree = 100;
  122. int g_Cert_Type = -1;
  123. int g_Cert_Delete = -1;
  124. @@ -223,7 +224,7 @@
  125. {cl_illegal, false, ""}, // Q
  126. {cl_illegal, false, ""}, // R
  127. {cl_illegal, false, ""}, // S
  128. - {cl_illegal, false, ""}, // T
  129. + {cl_integer, true, "_NTHREADS"}, // T
  130. {cl_illegal, false, ""}, // U
  131. {cl_boolean, false, "_VERBOSE"}, // V
  132. {cl_illegal, false, ""}, // W
  133. @@ -320,7 +321,10 @@
  134. \n\
  135. -g<o> Test for factors of GFN's. If -go then ONLY test for factors (no PRP).\n\
  136. -gx<o> Test for factors of \"extended\" GFN's. xGFN's form is a^2^n+b^2^n\n\
  137. -\n";
  138. +\n\
  139. +-T<number> performs tests using multiple threads.\n\
  140. +\n\
  141. +";
  142. LPCTSTR Help_Text5 = "\
  143. --===ADVANCED OPTIONS FOR DETERMINSTIC TESTS===--\n\
  144. \n\
  145. @@ -515,7 +519,7 @@
  146. if (cParameter == 0 && clList[iIndex].required)
  147. {
  148. PFOutput::EnableOneLineForceScreenOutput();
  149. - PFPrintfStderr("Switch %s requires a string parameter\n", LPCTSTR(s));
  150. + PFPrintfStderr("Switch %s requires an integer parameter\n", LPCTSTR(s));
  151. return false;
  152. };
  153.  
  154. @@ -526,7 +530,7 @@
  155. if (cParameter == 0 && clList[iIndex].required)
  156. {
  157. PFOutput::EnableOneLineForceScreenOutput();
  158. - PFPrintfStderr("Switch %s requires a string parameter\n", LPCTSTR(s));
  159. + PFPrintfStderr("Switch %s requires an integer parameter\n", LPCTSTR(s));
  160. return false;
  161. };
  162.  
  163. @@ -654,6 +658,7 @@
  164. }
  165.  
  166. gwinit2(&gwdata, sizeof(gwhandle), (char *) GWNUM_VERSION);
  167. + gwset_num_threads(&gwdata, g_Nthreads);
  168.  
  169. if (gwdata.GWERROR == GWERROR_VERSION_MISMATCH)
  170. {
  171. @@ -786,6 +791,18 @@
  172. g_CompositeAthenticationLevel = 5;
  173. }
  174.  
  175. + g_Nthreads=1; // default, run on 1 thread
  176. + pSymbol=psymRuntime->LookupSymbol("_NTHREADS");
  177. + if(pSymbol && pSymbol->GetSymbolType()==INTEGER_SYMBOL_TYPE)
  178. + {
  179. + Integer INthreads=*(((PFIntegerSymbol*)pSymbol)->GetValue());
  180. + char *cp = INthreads.Itoa();
  181. + g_Nthreads = atoi(cp);
  182. + delete[] cp;
  183. + if (g_Nthreads < 1)
  184. + g_Nthreads = 1;
  185. + }
  186. +
  187. // Communicate these values to any SCRIPT so that it knows what the
  188. // "defaults" for factorizing are.
  189. g_MinStartingPrimeToFactor=g_MaxStoppingPrimeToFactor=0;
  190. Index: pform/pfgw/phi_prp.cpp
  191. ===================================================================
  192. --- pform/pfgw/phi_prp.cpp (revision 643)
  193. +++ pform/pfgw/phi_prp.cpp (working copy)
  194. @@ -196,6 +196,7 @@
  195.  
  196. // calculate 2^iPhi mod Q
  197. gwinit2(&gwdata, sizeof(gwhandle), (char *) GWNUM_VERSION);
  198. + gwset_num_threads(&gwdata, g_Nthreads);
  199. gwsetmaxmulbyconst(&gwdata, 2); // maximum multiplier
  200.  
  201. if (CreateModulus(&Q, g_cpTestString, true)) return;
  202. @@ -265,6 +266,7 @@
  203. fftSize++;
  204.  
  205. gwinit2(&gwdata, sizeof(gwhandle), (char *) GWNUM_VERSION);
  206. + gwset_num_threads(&gwdata, g_Nthreads);
  207. gwsetmaxmulbyconst(&gwdata, iBase); // maximum multiplier
  208.  
  209. gwset_larger_fftlen_count(&gwdata, fftSize);
  210. Index: pform/pfio/pfscriptfns.cpp
  211. ===================================================================
  212. --- pform/pfio/pfscriptfns.cpp (revision 643)
  213. +++ pform/pfio/pfscriptfns.cpp (working copy)
  214. @@ -9,6 +9,7 @@
  215.  
  216. extern char g_ModularSieveString[256];
  217. extern int g_nIterationCnt;
  218. +extern int g_Nthreads;
  219.  
  220. bool CheckForFatalError(const char *caller, GWInteger *gwX, int currentIteration, int maxIterations, int fftSize);
  221.  
  222. @@ -688,6 +689,7 @@
  223. int i, s, iterations;
  224.  
  225. gwinit2(&gwdata, sizeof(gwhandle), (char *) GWNUM_VERSION);
  226. + gwset_num_threads(&gwdata, g_Nthreads);
  227.  
  228. CreateModulus(&n, modulus);
  229.  
  230. Index: pform/pfoo/algebra.cpp
  231. ===================================================================
  232. --- pform/pfoo/algebra.cpp (revision 643)
  233. +++ pform/pfoo/algebra.cpp (working copy)
  234. @@ -8,6 +8,7 @@
  235.  
  236. extern bool volatile g_bExitNow;
  237. extern char g_cpTestString[70];
  238. +extern int g_Nthreads;
  239.  
  240. FiniteField::~FiniteField()
  241. {
  242. @@ -34,6 +35,7 @@
  243. FieldZ::FieldZ(Integer *N)
  244. {
  245. gwinit2(&gwdata, sizeof(gwhandle), (char *) GWNUM_VERSION);
  246. + gwset_num_threads(&gwdata, g_Nthreads);
  247. gwsetmaxmulbyconst(&gwdata, GWMULBYCONST_MAX); // maximum multiplier
  248. CreateModulus(N, g_cpTestString);
  249. }
  250. @@ -209,6 +211,7 @@
  251. : ps1(NULL), ps2(NULL), ps3(NULL), ps4(NULL)
  252. {
  253. gwinit2(&gwdata, sizeof(gwhandle), (char *) GWNUM_VERSION);
  254. + gwset_num_threads(&gwdata, g_Nthreads);
  255. gwsetmaxmulbyconst(&gwdata, GWMULBYCONST_MAX); // maximum multiplier
  256. CreateModulus(N, g_cpTestString);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement