[Ecm-commits] r2607 - in trunk: . build.vc12/ecm build.vc12/libecm build.vc12/libecm_gpu

cvs commits ecm-commits at lists.gforge.inria.fr
Thu Feb 12 23:55:36 CET 2015


Author: brian_gladman
Date: 2015-02-12 23:55:36 +0100 (Thu, 12 Feb 2015)
New Revision: 2607

Modified:
   trunk/build.vc12/ecm/ecm.vcxproj
   trunk/build.vc12/libecm/libecm.vcxproj
   trunk/build.vc12/libecm/libecm.vcxproj.filters
   trunk/build.vc12/libecm_gpu/libecm_gpu.vcxproj
   trunk/memusage.c
   trunk/mpmod.c
Log:
Add peak memory use on Windows; put some declarations in C90 form; update Visual Studio build

Modified: trunk/build.vc12/ecm/ecm.vcxproj
===================================================================
--- trunk/build.vc12/ecm/ecm.vcxproj	2015-02-12 10:46:26 UTC (rev 2606)
+++ trunk/build.vc12/ecm/ecm.vcxproj	2015-02-12 22:55:36 UTC (rev 2607)
@@ -26,7 +26,7 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>
-    <PlatformToolset>v120</PlatformToolset>
+    <PlatformToolset>v110</PlatformToolset>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>
@@ -34,7 +34,7 @@
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>
-    <PlatformToolset>v120</PlatformToolset>
+    <PlatformToolset>v110</PlatformToolset>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>

Modified: trunk/build.vc12/libecm/libecm.vcxproj
===================================================================
--- trunk/build.vc12/libecm/libecm.vcxproj	2015-02-12 10:46:26 UTC (rev 2606)
+++ trunk/build.vc12/libecm/libecm.vcxproj	2015-02-12 22:55:36 UTC (rev 2607)
@@ -188,6 +188,7 @@
     <ClCompile Include="..\..\listz_handle.c" />
     <ClCompile Include="..\..\lucas.c" />
     <ClCompile Include="..\..\median.c" />
+    <ClCompile Include="..\..\memusage.c" />
     <ClCompile Include="..\..\mpmod.c" />
     <ClCompile Include="..\..\mpzspm.c" />
     <ClCompile Include="..\..\mpzspv.c" />

Modified: trunk/build.vc12/libecm/libecm.vcxproj.filters
===================================================================
--- trunk/build.vc12/libecm/libecm.vcxproj.filters	2015-02-12 10:46:26 UTC (rev 2606)
+++ trunk/build.vc12/libecm/libecm.vcxproj.filters	2015-02-12 22:55:36 UTC (rev 2607)
@@ -136,6 +136,9 @@
     <ClCompile Include="..\..\aprtcle\mpz_aprcl.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\memusage.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\ecm-ecm.h">

Modified: trunk/build.vc12/libecm_gpu/libecm_gpu.vcxproj
===================================================================
--- trunk/build.vc12/libecm_gpu/libecm_gpu.vcxproj	2015-02-12 10:46:26 UTC (rev 2606)
+++ trunk/build.vc12/libecm_gpu/libecm_gpu.vcxproj	2015-02-12 22:55:36 UTC (rev 2607)
@@ -247,6 +247,7 @@
     <ClCompile Include="..\..\listz_handle.c" />
     <ClCompile Include="..\..\lucas.c" />
     <ClCompile Include="..\..\median.c" />
+    <ClCompile Include="..\..\memusage.c" />
     <ClCompile Include="..\..\mpmod.c" />
     <ClCompile Include="..\..\mpzspm.c" />
     <ClCompile Include="..\..\mpzspv.c" />

Modified: trunk/memusage.c
===================================================================
--- trunk/memusage.c	2015-02-12 10:46:26 UTC (rev 2606)
+++ trunk/memusage.c	2015-02-12 22:55:36 UTC (rev 2607)
@@ -19,6 +19,8 @@
 http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
 
+#ifndef _MSC_VER
+
 #include <stdio.h>
 #include <sys/types.h>
 #include <unistd.h>
@@ -60,3 +62,17 @@
     }
 }
 
+#else
+
+#include <windows.h>
+#include <psapi.h>
+
+long
+PeakMemusage(void)
+{
+    PROCESS_MEMORY_COUNTERS info;
+    GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info));
+    return (long)(info.PeakWorkingSetSize >> 10);
+}
+
+#endif

Modified: trunk/mpmod.c
===================================================================
--- trunk/mpmod.c	2015-02-12 10:46:26 UTC (rev 2606)
+++ trunk/mpmod.c	2015-02-12 22:55:36 UTC (rev 2607)
@@ -1176,8 +1176,12 @@
 void 
 mpres_pow (mpres_t R, const mpres_t BASE, const mpz_t EXP, mpmod_t modulus)
 {
-  ASSERT_NORMALIZED (BASE);
+    size_t k, expnbits, K, lw, n0, i;
+    mpres_t *B;
+    mp_limb_t w;
 
+    ASSERT_NORMALIZED(BASE);
+
   if (modulus->repr == ECM_MOD_MPZ)
     mpz_powm (R, BASE, EXP, modulus->orig_modulus);
   else if (modulus->repr == ECM_MOD_BASE2 || modulus->repr == ECM_MOD_MODMULN ||
@@ -1205,16 +1209,15 @@
       /* here the most significant limb with any set bits is in expbits, */
       /* bitmask is set to mask in the msb of expbits */
 
-      size_t k = 1; /* sliding window size */
-      size_t expnbits = mpz_sizeinbase (EXP, 2);
+      k = 1; /* sliding window size */
+      expnbits = mpz_sizeinbase (EXP, 2);
       /* the average number of multiplications is 2^(k-1) + expnbits / (k+1) */
       while ((1 << (k-1)) + expnbits / (k + 1) > (1 << k) + expnbits / (k + 2))
         k ++;
       /* precompute BASE^i for i = 2, 3, 5, ..., 2^k-1 */
-      mpres_t *B;
-      size_t K = 1UL << (k - 1);
+      K = 1UL << (k - 1);
       B = malloc (K * sizeof (mpres_t));
-      for (size_t i = 0; i < K; i++)
+      for (i = 0; i < K; i++)
         {
           mpres_init (B[i], modulus);
           mpres_realloc (B[i], modulus);
@@ -1228,10 +1231,10 @@
       
       mpz_set (modulus->temp2, BASE);
       bitmask >>= 1;
-      mp_limb_t w = 0; /* invariant: temp2 has to be multiplied by BASE^w */
-      size_t lw = 0;   /* number of bits in w */
+      w = 0; /* invariant: temp2 has to be multiplied by BASE^w */
+      lw = 0;   /* number of bits in w */
       expnbits --;     /* number of remaining bits to deal with */
-      size_t n0 = 0;   /* smallest bit index of current window */
+      n0 = 0;   /* smallest bit index of current window */
 
       while (1) 
         {
@@ -1272,7 +1275,7 @@
       if (w != 0)
         mpres_pow_mul (modulus->temp2, (w == 1) ? BASE : B[w/2],
                        modulus->temp2, modulus);
-      for (size_t i = 0; i < K; i++)
+      for (i = 0; i < K; i++)
         mpres_clear (B[i], modulus);
       free (B);
       mpz_set (R, modulus->temp2);



More information about the Ecm-commits mailing list