mersenneforum.org  

Go Back   mersenneforum.org > Factoring Projects > Msieve

Reply
 
Thread Tools
Old 2017-02-02, 23:45   #1
LegionMammal978
 
Jan 2017
Glory to Arstotzka!

2×7 Posts
Default Compiling Msieve with GPU support

Argh, so many issues, currently new to this... Currently running on a x64 Ubuntu box with an i7 and a GTX1060. First off, how does one set up/compile Msieve to work with the GPU? Can't find any good instructions on this. Secondly, around what size number does GPU processing actually make a difference?
LegionMammal978 is offline   Reply With Quote
Old 2017-02-03, 14:53   #2
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

3,541 Posts
Default

Surprised there are no answers yet... I'll try:

First, you need to set up a working CUDA installation so the nVidia driver, nvcc compiler and paths are all working. It's best to install the samples and check that some of them run. The CUDA installation document should show all those steps.

After you have all that running, then you can compile msieve with CUDA=1. msieve should automatically use the GPU during the poly select phase. Actually, it only uses it during one step of the phase, but there should be an immediate and noticeable advantage with any size composite.
EdH is offline   Reply With Quote
Old 2017-02-08, 11:58   #3
LegionMammal978
 
Jan 2017
Glory to Arstotzka!

1410 Posts
Default

Quote:
Originally Posted by EdH View Post
After you have all that running, then you can compile msieve with CUDA=1. msieve should automatically use the GPU during the poly select phase. Actually, it only uses it during one step of the phase, but there should be an immediate and noticeable advantage with any size composite.
I just tried getting this to work. However, after correcting the search paths in the Makefiles, it's giving me this:

Code:
libmsieve.a(stage1.no): In function `poly_stage1_run':
stage1.c:(.text+0xc01): undefined reference to `sieve_lattice_cpu'
collect2: error: ld returned 1 exit status
Makefile:273: recipe for target 'all' failed
make: *** [all] Error 1
Any ideas?
LegionMammal978 is offline   Reply With Quote
Old 2017-02-08, 15:24   #4
jasonp
Tribal Bullet
 
jasonp's Avatar
 
Oct 2004

353410 Posts
Default

As EdH mentioned, you have to invoke the Msieve makefile with

make all CUDA=1

If you had previously built Msieve with CPU polynomial selection you first have to 'make clean'; the dependency tracking in the makefile cannot handle switching from CPU to GPU.

Last fiddled with by jasonp on 2017-02-08 at 15:25
jasonp is offline   Reply With Quote
Old 2017-02-08, 16:57   #5
chris2be8
 
chris2be8's Avatar
 
Sep 2009

22·32·5·11 Posts
Default

Or unpack msieve's source into another directory and run "make all CUDA=1" in there. That way your existing copy of msieve will still be available for use if CUDA doesn't work for some reason (I've had a lot of "fun" getting msieve to work with CUDA).

Chris
chris2be8 is offline   Reply With Quote
Old 2017-02-08, 23:06   #6
LegionMammal978
 
Jan 2017
Glory to Arstotzka!

2×7 Posts
Default

More problems! I did a make clean as suggested, fixed another path, and it got further in compilation, but now it's giving me this:

Code:
gcc -O3 -fomit-frame-pointer -march=native -D_FILE_OFFSET_BITS=64 -DNDEBUG -D_LARGEFILE64_SOURCE  -Wall -W -DMSIEVE_SVN_VERSION="\"Unversioned directory\"" -I. -Iaprcl -Iinclude -Ignfs -Ignfs/poly -Ignfs/poly/stage1 -I"/home/lm978/cuda-8.0/include" -Icub -DHAVE_CUDA demo.c -o msieve  \
        libmsieve.a -ldl  -lz -lgmp -lm -lpthread
demo.c: In function ‘get_random_seeds’:
demo.c:54:3: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
   fread(&tmp_seed1, sizeof(uint32), (size_t)1, rand_device);
   ^
demo.c:55:3: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
   fread(&tmp_seed2, sizeof(uint32), (size_t)1, rand_device);
   ^
demo.c: In function ‘main’:
demo.c:578:4: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
    fgets(buf, (int)sizeof(buf), stdin);
    ^
demo.c:598:4: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
    fgets(buf, (int)sizeof(buf), infile);
    ^
libmsieve.a(stage1_sieve_gpu.no): In function `gpu_thread_data_free':
stage1_sieve_gpu.c:(.text+0x42): undefined reference to `cuEventDestroy_v2'
stage1_sieve_gpu.c:(.text+0x56): undefined reference to `cuEventDestroy_v2'
stage1_sieve_gpu.c:(.text+0x6e): undefined reference to `cuMemFree_v2'
stage1_sieve_gpu.c:(.text+0x7f): undefined reference to `cuMemFree_v2'
stage1_sieve_gpu.c:(.text+0x90): undefined reference to `cuMemFree_v2'
stage1_sieve_gpu.c:(.text+0xa1): undefined reference to `cuMemFree_v2'
stage1_sieve_gpu.c:(.text+0xc4): undefined reference to `cuStreamDestroy_v2'
stage1_sieve_gpu.c:(.text+0xde): undefined reference to `cuMemFree_v2'
stage1_sieve_gpu.c:(.text+0x144): undefined reference to `cuMemFree_v2'
stage1_sieve_gpu.c:(.text+0x151): undefined reference to `cuMemFree_v2'
stage1_sieve_gpu.c:(.text+0x174): undefined reference to `cuMemFree_v2'
stage1_sieve_gpu.c:(.text+0x195): undefined reference to `cuCtxDestroy_v2'
libmsieve.a(stage1_sieve_gpu.no): In function `store_p_soa':
stage1_sieve_gpu.c:(.text+0x461): undefined reference to `cuMemFree_v2'
stage1_sieve_gpu.c:(.text+0x473): undefined reference to `cuMemFree_v2'
stage1_sieve_gpu.c:(.text+0x48e): undefined reference to `cuMemAlloc_v2'
stage1_sieve_gpu.c:(.text+0x4aa): undefined reference to `cuMemAlloc_v2'
libmsieve.a(stage1_sieve_gpu.no): In function `store_specialq':
stage1_sieve_gpu.c:(.text+0x628): undefined reference to `cuMemFree_v2'
stage1_sieve_gpu.c:(.text+0x641): undefined reference to `cuMemAlloc_v2'
libmsieve.a(stage1_sieve_gpu.no): In function `gpu_thread_data_init':
stage1_sieve_gpu.c:(.text+0x6d2): undefined reference to `cuCtxCreate_v2'
stage1_sieve_gpu.c:(.text+0x70f): undefined reference to `cuModuleLoad'
stage1_sieve_gpu.c:(.text+0x7ba): undefined reference to `cuStreamCreate'
stage1_sieve_gpu.c:(.text+0x7d0): undefined reference to `cuMemAlloc_v2'
stage1_sieve_gpu.c:(.text+0x7ff): undefined reference to `cuMemsetD8_v2'
stage1_sieve_gpu.c:(.text+0x91b): undefined reference to `cuMemAlloc_v2'
stage1_sieve_gpu.c:(.text+0x938): undefined reference to `cuMemAlloc_v2'
stage1_sieve_gpu.c:(.text+0x999): undefined reference to `cuMemAlloc_v2'
stage1_sieve_gpu.c:(.text+0x9df): undefined reference to `cuMemAlloc_v2'
stage1_sieve_gpu.c:(.text+0x9f3): undefined reference to `cuMemAlloc_v2'
libmsieve.a(stage1_sieve_gpu.no):stage1_sieve_gpu.c:(.text+0xa09): more undefined references to `cuMemAlloc_v2' follow
libmsieve.a(stage1_sieve_gpu.no): In function `gpu_thread_data_init':
stage1_sieve_gpu.c:(.text+0xa42): undefined reference to `cuEventCreate'
stage1_sieve_gpu.c:(.text+0xa5b): undefined reference to `cuEventCreate'
stage1_sieve_gpu.c:(.text+0xaf5): undefined reference to `cuModuleLoad'
stage1_sieve_gpu.c:(.text+0xb7f): undefined reference to `cuModuleLoad'
stage1_sieve_gpu.c:(.text+0xbaa): undefined reference to `cuModuleLoad'
stage1_sieve_gpu.c:(.text+0xc84): undefined reference to `cuFuncSetBlockShape'
libmsieve.a(stage1_sieve_gpu.no): In function `task_data_run':
stage1_sieve_gpu.c:(.text+0x1176): undefined reference to `cuMemcpyHtoDAsync_v2'
stage1_sieve_gpu.c:(.text+0x1196): undefined reference to `cuMemcpyHtoDAsync_v2'
stage1_sieve_gpu.c:(.text+0x1469): undefined reference to `cuEventRecord'
stage1_sieve_gpu.c:(.text+0x149e): undefined reference to `cuMemcpyHtoDAsync_v2'
stage1_sieve_gpu.c:(.text+0x14c8): undefined reference to `cuMemsetD8Async'
stage1_sieve_gpu.c:(.text+0x1731): undefined reference to `cuFuncSetBlockShape'
stage1_sieve_gpu.c:(.text+0x1758): undefined reference to `cuLaunchGridAsync'
stage1_sieve_gpu.c:(.text+0x18e1): undefined reference to `cuLaunchGridAsync'
stage1_sieve_gpu.c:(.text+0x18f9): undefined reference to `cuEventRecord'
stage1_sieve_gpu.c:(.text+0x190d): undefined reference to `cuEventSynchronize'
stage1_sieve_gpu.c:(.text+0x1930): undefined reference to `cuEventElapsedTime'
stage1_sieve_gpu.c:(.text+0x199c): undefined reference to `cuMemcpyDtoHAsync_v2'
stage1_sieve_gpu.c:(.text+0x19ad): undefined reference to `cuStreamSynchronize'
stage1_sieve_gpu.c:(.text+0x1b21): undefined reference to `cuMemsetD8Async'
stage1_sieve_gpu.c:(.text+0x215d): undefined reference to `cuMemFree_v2'
stage1_sieve_gpu.c:(.text+0x217f): undefined reference to `cuMemAlloc_v2'
libmsieve.a(cuda_xface.o): In function `gpu_init':
cuda_xface.c:(.text+0x246): undefined reference to `cuInit'
cuda_xface.c:(.text+0x256): undefined reference to `cuDeviceGetCount'
cuda_xface.c:(.text+0x280): undefined reference to `cuDeviceGet'
cuda_xface.c:(.text+0x29d): undefined reference to `cuDeviceGetName'
cuda_xface.c:(.text+0x2b6): undefined reference to `cuDeviceComputeCapability'
cuda_xface.c:(.text+0x2cc): undefined reference to `cuDeviceGetProperties'
cuda_xface.c:(.text+0x335): undefined reference to `cuDeviceTotalMem_v2'
cuda_xface.c:(.text+0x34f): undefined reference to `cuDeviceGetAttribute'
cuda_xface.c:(.text+0x369): undefined reference to `cuDeviceGetAttribute'
cuda_xface.c:(.text+0x37e): undefined reference to `cuDeviceGetAttribute'
libmsieve.a(cuda_xface.o): In function `gpu_launch_init':
cuda_xface.c:(.text+0x4b6): undefined reference to `cuModuleGetFunction'
cuda_xface.c:(.text+0x4cc): undefined reference to `cuFuncGetAttribute'
cuda_xface.c:(.text+0x564): undefined reference to `cuParamSetSize'
libmsieve.a(cuda_xface.o): In function `gpu_launch_set':
cuda_xface.c:(.text+0x637): undefined reference to `cuParamSetv'
cuda_xface.c:(.text+0x687): undefined reference to `cuParamSetv'
cuda_xface.c:(.text+0x6ca): undefined reference to `cuParamSeti'
cuda_xface.c:(.text+0x6fa): undefined reference to `cuParamSeti'
cuda_xface.c:(.text+0x737): undefined reference to `cuParamSetv'
collect2: error: ld returned 1 exit status
Makefile:273: recipe for target 'all' failed
make: *** [all] Error 1
LegionMammal978 is offline   Reply With Quote
Old 2017-02-09, 04:28   #7
jasonp
Tribal Bullet
 
jasonp's Avatar
 
Oct 2004

67168 Posts
Default

Running make with CUDA=1 should have included '-lcuda' on the link line for the Msieve demo, per line 64 in the version of Makefile on sourceforge. That should be enough, the GPU code compiled into the C source uses only the Nvidia driver API.

The makefile for the sort engine uses nvcc throughout, which links in the Nvidia C++ interface automatically.

Last fiddled with by jasonp on 2017-02-09 at 04:30
jasonp is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Msieve with GPU support jasonp Msieve 223 2011-03-11 19:30
Problem compiling msieve with gcc 4.4.2 chris2be8 Msieve 5 2010-02-22 18:35
Msieve with GNFS support R.D. Silverman Msieve 465 2010-01-11 20:59
Error compiling msieve Wishper Msieve 2 2009-12-09 01:31
Compiling Msieve 1.39 on Windows Jeff Gilchrist Msieve 20 2009-02-21 22:43

All times are UTC. The time now is 23:55.

Wed Jan 20 23:55:15 UTC 2021 up 48 days, 20:06, 0 users, load averages: 1.52, 1.56, 1.60

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.