找回密码
 欢迎注册
楼主: 〇〇

[讨论] mathe能否提供更新的windows版gmp库

[复制链接]
发表于 2010-9-9 10:12:01 | 显示全部楼层
10# 〇〇 你好像没有make install,
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-9 10:22:15 | 显示全部楼层
你要静态还是动态的,要不要支持C++,要不要开断言,我可以拷贝你
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2010-9-10 05:47:53 | 显示全部楼层
都要呢...
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-10 11:34:28 | 显示全部楼层
13# 〇〇 在GCC4.5.1下编译出来的。 --enable-cxx --enable-assert gmp5.0.1-static.7z (274.32 KB, 下载次数: 26) gmp5.0.1-shared.7z (276.69 KB, 下载次数: 4)
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2010-9-11 10:29:35 | 显示全部楼层
谢谢
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-11 20:35:37 | 显示全部楼层
是在四核机器下编译的, build system type .... core2-pc-mingw32
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2010-10-20 21:03:35 | 显示全部楼层
  1. /*William,
  2. Here is a simple program that computes PI (using GMP library) to compare the performance differences for "Cilk V2 cilk_spawn", "OpenMP 3.0 task" or serially. The program was modified from the source found at http://gmplib.org/list-archives/gmp-discuss/2010-April/004117.html and any mistakes are my own.
  3. /* Pi computation using Chudnovsky's algortithm.
  4. * Copyright 2002, 2005 Hanhong Xue (macroxue at yahoo dot com)
  5. * Slightly modified 2005 by Torbjorn Granlund to allow more than 2G
  6. digits to be computed.
  7. * Modified 2010 by David Carver (dcarver at tacc dot utexas dot edu) to
  8. demonstrate a parallel recursive version of the gmp-chudnovsky program
  9. using the Intel's C++ Compiler XE 12.0 with either "Cilk V2" or "OpenMP 3.0 task".
  10. \$ icc -V
  11. Intel(R) C Compiler XE for applications running on Intel(R) 64, Version 12.0.0 Beta Build 20100512
  12. Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
  13. To compile for serial execution
  14. \$ icc -O3 -o pgmp-chudnovsky pgmp-chudnovsky.c -lgmp -limf
  15. and run:
  16. \$ ./pgmp-chudnovsky 100000000 0
  17. #terms=7051366 depth=24 nprocs=12 SERIAL
  18. bs cputime = 207.030 wallclock = 207.060
  19. total cputime = 241.660 wallclock = 241.694
  20. P size=248778666 digits (2.487787)
  21. Q size=248778659 digits (2.487787)
  22. To compile for parallel Cilk V2 execution:
  23. \$ icc -DOCILK -O3 -o pgmp-chudnovsky pgmp-chudnovsky.c -lgmp -limf
  24. and you may specify the number of workers with the Cilk V2 environment variable CILK_NPROC
  25. \$ export CILK_NWORKERS=12
  26. \$ ./pgmp-chudnovsky 100000000 0
  27. #terms=7051366 depth=24 nprocs=12 CILK_NWORKERS=12
  28. bs cputime = 639.680 wallclock = 53.331
  29. total cputime = 674.790 wallclock = 88.448
  30. P size=248778666 digits (2.487787)
  31. Q size=248778659 digits (2.487787)
  32. To compile for a simple parallel OpenMP 3.0 Task execution:
  33. \$ icc -openmp -O3 -o pgmp-chudnovsky pgmp-chudnovsky.c -lgmp -limf
  34. and you may specify the number of threads with the OpenMP environment variable OMP_NUM_THREADS
  35. \$ export OMP_NUM_THREADS=12
  36. \$ ./pgmp-chudnovsky 100000000 0
  37. #terms=7051366 depth=24 nprocs=12 OMP_NUM_THREADS=12
  38. bs cputime = 710.110 wallclock = 59.223
  39. total cputime = 745.390 wallclock = 94.340
  40. P size=248778666 digits (2.487787)
  41. Q size=248778659 digits (2.487787)
  42. To get help run the program with no options:
  43. \$ ./pgmp-chudnovsky
  44. Syntax: ./pgmp-chudnovsky <digits> <option>
  45. <digits> digits of pi to output
  46. <option> 0 - just run (default)
  47. 1 - output decimal digits to stdout
  48. * Redistribution and use in source and binary forms,with or without
  49. * modification,are permitted provided that the following conditions are met:
  50. * 1. Redistributions of source code must retain the above copyright notice,
  51. * this list of conditions and the following disclaimer.
  52. * 2. Redistributions in binary form must reproduce the above copyright notice,
  53. * this list of conditions and the following disclaimer in the documentation
  54. * and/or other materials provided with the distribution.
  55. *
  56. * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  57. * IMPLIED WARRANTIES,INCLUDING,BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF
  58. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  59. * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT,INDIRECT,INCIDENTAL,
  60. * SPECIAL,EXEMPLARY,OR CONSEQUENTIAL DAMAGES (INCLUDING,BUT NOT LIMITED TO,
  61. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA,OR PROFITS;
  62. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  63. * WHETHER IN CONTRACT,STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR
  64. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,EVEN IF
  65. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  66. */
  67. #include <assert.h>
  68. #include <math.h>
  69. #include <stdio.h>
  70. #include <stdlib.h>
  71. #include <string.h>
  72. #include <time.h>
  73. //#include <sys/time.h>
  74. //#include <sys/sysinfo.h>
  75. #ifdef OCILK
  76. #include <cilk/cilk.h>
  77. #elif _OPENMP
  78. #include <omp.h>
  79. #endif /* OCILK */
  80. #include <gmp.h>
  81. #define A 13591409
  82. #define B 545140134
  83. #define C 640320
  84. #define D 12
  85. #define BITS_PER_DIGIT 3.32192809488736234787
  86. #define DIGITS_PER_ITER 14.1816474627254776555
  87. #define DOUBLE_PREC 53
  88. ////////////////////////////////////////////////////////////////////////////
  89. /*
  90. double wall_clock()
  91. {
  92. struct timeval timeval;
  93. (void) gettimeofday (&timeval,NULL);
  94. return (timeval.tv_sec + (timeval.tv_usec / 1000000.0));
  95. }
  96. */
  97. ////////////////////////////////////////////////////////////////////////////
  98. /* binary splitting */
  99. void
  100. bs(unsigned long a,unsigned long b,unsigned gflag,unsigned level,mpz_t pstack1,mpz_t qstack1,mpz_t gstack1)
  101. {
  102. unsigned long mid;
  103. mpz_t pstack2,qstack2,gstack2;
  104. if (b-a==1) {
  105. /*
  106. g(b-1,b) = (6b-5)(2b-1)(6b-1)
  107. p(b-1,b) = b^3 * C^3 / 24
  108. q(b-1,b) = (-1)^b*g(b-1,b)*(A+Bb).
  109. */
  110. mpz_set_ui(pstack1,b);
  111. mpz_mul_ui(pstack1,pstack1,b);
  112. mpz_mul_ui(pstack1,pstack1,b);
  113. mpz_mul_ui(pstack1,pstack1,(C/24)*(C/24));
  114. mpz_mul_ui(pstack1,pstack1,C*24);
  115. mpz_set_ui(gstack1,2*b-1);
  116. mpz_mul_ui(gstack1,gstack1,6*b-1);
  117. mpz_mul_ui(gstack1,gstack1,6*b-5);
  118. mpz_set_ui(qstack1,b);
  119. mpz_mul_ui(qstack1,qstack1,B);
  120. mpz_add_ui(qstack1,qstack1,A);
  121. mpz_mul (qstack1,qstack1,gstack1);
  122. if (b%2)
  123. mpz_neg(qstack1,qstack1);
  124. } else {
  125. /*
  126. p(a,b) = p(a,m) * p(m,b)
  127. g(a,b) = g(a,m) * g(m,b)
  128. q(a,b) = q(a,m) * p(m,b) + q(m,b) * g(a,m)
  129. */
  130. mid = a+(b-a)*0.5224; /* tuning parameter */
  131. mpz_init(pstack2);
  132. mpz_init(qstack2);
  133. mpz_init(gstack2);
  134. #ifdef OCILK
  135. cilk_spawn bs(mid,b,gflag,level+1,pstack2,qstack2,gstack2);
  136. bs(a,mid,1,level+1,pstack1,qstack1,gstack1);
  137. cilk_sync;
  138. #elif _OPENMP
  139. #pragma omp task firstprivate(mid,b,gflag,level) shared(pstack2,qstack2,gstack2)
  140. bs(mid,b,gflag,level+1,pstack2,qstack2,gstack2);
  141. #pragma omp task firstprivate(mid,a,gflag,level) shared(pstack1,qstack1,gstack1)
  142. bs(a,mid,1,level+1,pstack1,qstack1,gstack1);
  143. #pragma omp taskwait
  144. #else /* SERIAL */
  145. bs(mid,b,gflag,level+1,pstack2,qstack2,gstack2);
  146. bs(a,mid,1,level+1,pstack1,qstack1,gstack1);
  147. #endif /* OCILK */
  148. mpz_mul(pstack1,pstack1,pstack2);
  149. mpz_mul(qstack1,qstack1,pstack2);
  150. mpz_mul(qstack2,qstack2,gstack1);
  151. mpz_add(qstack1,qstack1,qstack2);
  152. if (gflag) {
  153. mpz_mul(gstack1,gstack1,gstack2);
  154. }
  155. mpz_clear(pstack2);
  156. mpz_clear(qstack2);
  157. mpz_clear(gstack2);
  158. }
  159. }
  160. int
  161. main(int argc,char *argv[])
  162. {
  163. mpf_t pi,qi;
  164. mpz_t pstack,qstack,gstack;
  165. unsigned long terms,d=100,out=0,depth,psize,qsize;
  166. clock_t begin,end;
  167. double wbegin,wend;
  168. char *prog_name;
  169. prog_name = argv[0];
  170. if (argc==1) {
  171. fprintf(stderr,"\nSyntax: %s <digits> <option>\n",prog_name);
  172. fprintf(stderr," <digits> digits of pi to output\n");
  173. fprintf(stderr," <option> 0 - just run (default)\n");
  174. fprintf(stderr," 1 - output decimal digits to stdout\n");
  175. exit(1);
  176. }
  177. if (argc>1)
  178. d = strtoul(argv[1],0,0);
  179. if (argc>2)
  180. out = atoi(argv[2]);
  181. begin = clock();
  182. //wbegin = wall_clock();
  183. terms = d/DIGITS_PER_ITER;
  184. depth = 0;
  185. while ((1L<<depth)<terms)
  186. depth++;
  187. depth++;
  188. mpz_init(pstack);
  189. mpz_init(qstack);
  190. mpz_init(gstack);
  191. /* begin binary splitting process */
  192. if (terms<=0) {
  193. mpz_set_ui(pstack,1);
  194. mpz_set_ui(qstack,0);
  195. mpz_set_ui(gstack,1);
  196. } else {
  197. #ifdef OCILK
  198. fprintf(stderr,"#terms=%ld depth=%ld nprocs=%d CILK_NWORKERS=%d\n",terms,depth,1/*get_nprocs()*/,
  199. __cilkrts_get_nworkers());
  200. bs(0,terms,0,0,pstack,qstack,gstack);
  201. #elif _OPENMP
  202. #pragma omp parallel
  203. #pragma omp single nowait
  204. {
  205. fprintf(stderr,"#terms=%ld depth=%ld nprocs=%d OMP_NUM_THREADS=%d\n",terms,depth,1/*get_nprocs()*/,
  206. omp_get_num_threads());
  207. bs(0,terms,0,0,pstack,qstack,gstack);
  208. }
  209. #else /* SERIAL */
  210. fprintf(stderr,"#terms=%ld depth=%ld nprocs=%d SERIAL\n",terms,depth,1/*get_nprocs()*/);
  211. bs(0,terms,0,0,pstack,qstack,gstack);
  212. #endif /* OCILK */
  213. }
  214. end = clock();
  215. //wend = wall_clock();
  216. fprintf(stderr,"bs cputime = %6.3f wallclock = %6.3f\n",
  217. (double)(end-begin)/CLOCKS_PER_SEC,/*(wend-wbegin)*/1);
  218. fflush(stderr);
  219. mpz_clear(gstack);
  220. /* prepare to convert integers to floats */
  221. mpf_set_default_prec((long int)(d*BITS_PER_DIGIT+16));
  222. /*
  223. p*(C/D)*sqrt(C)
  224. pi = -----------------
  225. (q+A*p)
  226. */
  227. psize = mpz_sizeinbase(pstack,10);
  228. qsize = mpz_sizeinbase(qstack,10);
  229. mpz_addmul_ui(qstack,pstack,A);
  230. mpz_mul_ui(pstack,pstack,C/D);
  231. mpf_init(pi);
  232. mpf_set_z(pi,pstack);
  233. mpz_clear(pstack);
  234. mpf_init(qi);
  235. mpf_set_z(qi,qstack);
  236. mpz_clear(qstack);
  237. /* final step */
  238. mpf_div(qi,pi,qi);
  239. mpf_sqrt_ui(pi,C);
  240. mpf_mul(qi,qi,pi);
  241. mpf_clear(pi);
  242. end = clock();
  243. //wend = wall_clock();
  244. /* output Pi and timing statistics */
  245. fprintf(stderr,"total cputime = %6.3f wallclock = %6.3f\n",
  246. (double)(end-begin)/CLOCKS_PER_SEC,1/*(wend-wbegin)*/);
  247. fflush(stderr);
  248. printf(" P size=%ld digits (%f)\n"
  249. " Q size=%ld digits (%f)\n",
  250. psize,(double)psize/d,qsize,(double)qsize/d);
  251. if (out&1) {
  252. printf("pi(0,%ld)=\n",terms);
  253. mpf_out_str(stdout,10,d+2,qi);
  254. printf("\n");
  255. }
  256. /* free float resources */
  257. mpf_clear(qi);
  258. exit (0);
  259. }
复制代码
D:\lt\dl\gmp421>cl chudnovsky.cpp -I .\include /link D:\lt\dl\gmp421\lib\Win32\Release\gmp.lib Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86 Copyright (C) Microsoft Corporation 1984-2002. All rights reserved. chudnovsky.cpp Microsoft (R) Incremental Linker Version 7.10.3077 Copyright (C) Microsoft Corporation. All rights reserved. /out:chudnovsky.exe D:\lt\dl\gmp421\lib\Win32\Release\gmp.lib chudnovsky.obj LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library gmp.lib(get_str.obj) : error LNK2019: unresolved external symbol __ftol2_sse referenced in function ___gmpf_get_str chudnovsky.exe : fatal error LNK1120: 1 unresolved externals
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2010-10-21 10:30:51 | 显示全部楼层
自己利用 http://www.mpir.org/http://www.tortall.net/projects/yasm/wiki/Download 做出来了 configure make to_gmp
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2010-10-21 10:42:03 | 显示全部楼层
gpi被去掉了计时,用timer代替

Timer.rar

1.75 KB, 下载次数: 0, 下载积分: 金币 -1 枚, 经验 1 点, 下载 1 次

mpir.part2.rar

187.21 KB, 下载次数: 0, 下载积分: 金币 -1 枚, 经验 1 点, 下载 1 次

毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2010-10-21 10:42:35 | 显示全部楼层
512限制

mpir.part1.rar

500 KB, 下载次数: 0, 下载积分: 金币 -1 枚, 经验 1 点, 下载 1 次

毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-11-22 15:54 , Processed in 0.031592 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表