MacBook Pro 编译支持CUDA的MSIEVE

之前试过在CentOS 6上编译GMP-ECM和MSIEVE,后来有一天发现本机的MacPorts带的GMP-ECM不是最新版,当前6.4.4的情况下,MacPorts里的才6.3.
顺道也想侥幸一下看看这个2012款的rmbp能不能上CUDA,于是开始折腾。

环境

MacBook Pro with Retina Display 2012 (GT 650 M)
OS X 10.10.4
MacPorts

安装CUDA环境

CUDA Toolkit官方下载地址是:https://developer.nvidia.com/cuda-downloads
下载里目前最新版本是7.0.29,但是下载完成之后设置里还会提示有新版。
另外,Nvidia官方还给了个NVIDIA CUDA Getting Started Guide for Mac OS X.
我就简单地装了这个toolkit 没配环境变了。

第一次尝试

最早的尝试基于MacPorts自带的gmp和gmp-ecm编译CUDA版本的msieve,顺道还编译了个CPU版本的

这俩拿 RSA-39 的跑,都正常。但是自己生成了个RSA-256的,就有个ECM里报出的assert,没法工作。于是尝试编译ecm。
中间试过好几种方案,最后记录最后的版本

最新版 GMP, GMP-ECM, MSIEVE

最新版 GMP-ECM 也自带GPU的计算了,于是我也就把这个加了进去。

首先,从项目源上拉下最新版本

编译 GMP,原本是拉的最新release,但是中间遇到了一些问题,asm的编译不过去,于是也用trunk了。

编译 ECM

第一次configure的时候报当前系统不支持cuda,发现了个bug,报了官方,然后继续了,又发现这个错误:

ar -tv .libs/libecm.a,发现包里还有个libgmp.a,ar -d干掉就好了

但是运行的时候

看到@rpath,研究了半天,确信是跟 linux ldconfig 类似的问题,但是搜到的基本都是XCode如何修改。。。
最后发现是之前文档里提示加环境变量的问题:

编译MSIEVE
这个更麻烦,主要原因是7.x的CUDA不支持sm_1x,而MSIEVE里试图编译了 sm_11, sm_13, sm_20 三个架构。

错误如下

因为GT 650M 最高支持3.0的架构,于是我去改了下代码,包括:

至少,需要修改前两个Makefile,把sm_11和sm_13的编译选项删掉

运行

GPU版本的msieve运行需要b40c/sort_engine_smXX.so,所以如果要移动目录,需要保证这个.so的相对位置。

切回来,花屏。

换个

而,MSIEVE的GPU计算部分只在NFS polynomial selection里有用,其他过程没区别,于是白瞎了。

MacBook Pro 编译支持CUDA的MSIEVE by @sskaje: https://sskaje.me/2015/07/macbook-pro-%e7%bc%96%e8%af%91%e6%94%af%e6%8c%81cuda%e7%9a%84msieve/

Incoming search terms:

Factoring Integer on OS X with CADO-NFS

Environment: Mac OS X 10.10, MacPorts 2.3.3, CADO-NFS 2.1.1

Dependencies

Make sure all dependencies are installed.
CADO-NFS Required software tools

Required software tools

GMP: usually installed in most Linux distributions (on some Linux distributions you need to install libgmp*-dev including gmp.h, which is not installed by default). Note: make sure to configure GMP with –enable-shared so that a shared library is installed (libgmp.so under Linux) otherwise CADO-NFS might not compile. GMP 5 (or newer) is required.
GCC 4.4 or later ; some others compilers might work, but are unsupported. Both C and C++ compilers are required, with C99 support.
GNU make and CMake (2.6.3 or later) for building (CMake is installed on the fly if missing. This feature requires an Internet connection.)
Support for posix threads.
The main cadofactor.py script uses a lot of unix tools: Python, Python3, ssh, rsync, gzip to mention but a few.

Install

just type make after tar xvf

Test

Msieve

Using msieve 1.51 from MacPorts and CADO-NFS. The integer is 179399505810976971998364784462504058921, used in old versions of IntelliJ IDEA.
Msieve find its factor in 1 second, no extra parameter used.

CADO-NFS

Make sure your hostname is added to /etc/hosts, or you’ll get error like:

And, the number is to small for CADO-NFS, you have to copy a params file for this.

Here is the output of factor.sh

Maybe CADO-NFS is not really good for small integers.

Factoring Integer on OS X with CADO-NFS by @sskaje: https://sskaje.me/2015/06/factoring-integer-os-cado-nfs/

Incoming search terms:

Upsource

Jetbrains’ upsource is used for repository browsing and code review.
Free 10-user license is included, for more users you have to buy license.

You are not authorised to read all content in this post.

Please login…

Upsource by @sskaje: https://sskaje.me/2015/03/upsource/

Incoming search terms:

Jetbrains’ youtrack license & RSA algorithm study

You are not authorised to read all content in this post.

Please login…

Jetbrains’ youtrack license & RSA algorithm study by @sskaje: https://sskaje.me/2013/12/jetbrains-youtrack-license-rsa-algorithm-study/

Jetbrains’ ReSharper/DotTrace/DotCover keygen code study

You are not authorised to read all content in this post.

Please login…

Jetbrains’ ReSharper/DotTrace/DotCover keygen code study by @sskaje: https://sskaje.me/2013/12/jetbrains-resharperdottrace-keygen-code-study/

Incoming search terms: