Compile errors on OS X

82 views
Skip to first unread message

s.layton

unread,
Feb 4, 2010, 3:11:34 PM2/4/10
to opencurrent-users
I'm attempting to compile & run opencurrent on OS X (10.6 - snow
leopard) and am getting the following compile errors -- I know the
code isn't supported on OS X but is there likely to be some kind of
easy fix?

[ 1%] Building NVCC (Device) object ocuutil/./
ocuutil_generated_kernel_wrapper.cu.o
[ 2%] Building NVCC (Device) object ocuutil/./
ocuutil_generated_timer.cu.o
[ 4%] Building NVCC (Device) object ocuutil/./
ocuutil_generated_memory.cu.o
Scanning dependencies of target ocuutil
[ 5%] Building CXX object ocuutil/CMakeFiles/ocuutil.dir/
timing_pool.cpp.o
[ 7%] Building CXX object ocuutil/CMakeFiles/ocuutil.dir/
imagefile.cpp.o
Linking CXX static library libocuutil.a
[ 7%] Built target ocuutil
[ 8%] Building NVCC (Device) object ocustorage/./
ocustorage_generated_grid3dboundary.cu.o
/usr/include/c++/4.2.1/new(95): error: first parameter of allocation
function must be of type "size_t"

/usr/include/c++/4.2.1/new(96): error: first parameter of allocation
function must be of type "size_t"

/usr/include/c++/4.2.1/new(99): error: first parameter of allocation
function must be of type "size_t"

/usr/include/c++/4.2.1/new(100): error: first parameter of allocation
function must be of type "size_t"

/usr/include/c++/4.2.1/new(105): error: first parameter of allocation
function must be of type "size_t"

/usr/include/c++/4.2.1/new(106): error: first parameter of allocation
function must be of type "size_t"

6 errors detected in the compilation of "/tmp/
tmpxft_00014d6b_00000000-4_grid3dboundary.cpp1.ii".
CMake Error at ocustorage_generated_grid3dboundary.cu.o.cmake:205
(message):
Error generating file
/Users/simon/mercurial/opencurrent/sm13_rel/ocustorage/./
ocustorage_generated_grid3dboundary.cu.o


make[2]: *** [ocustorage/./ocustorage_generated_grid3dboundary.cu.o]
Error 1
make[1]: *** [ocustorage/CMakeFiles/ocustorage.dir/all] Error 2
make: *** [all] Error 2

JonCohen

unread,
Feb 4, 2010, 3:28:08 PM2/4/10
to opencurrent-users
Hm, I've never tested on OSX. gcc 4.2 should work with cuda, but all
of the standard libraries are a bit off from each other. My guess is
that it's some type of nvcc/gcc version mismatch. I'd suggest posting
on the cuda forums:

http://forums.nvidia.com/index.php?showforum=75

I'll ask around internally if anyone knows of version
incompatibilities.

What version of cuda, nvcc, and OSX are you using, by the way?

Jonathan Cohen

unread,
Feb 4, 2010, 5:02:56 PM2/4/10
to opencurrent-users
Ok, I asked internally and there are some bumps with OSX 10.6 (is that what you're on?)  Here's what I found out:


10.6 introduced a bunch of crazy things, like their new GCD blocks mechanism, into a bunch of standard header files.  nvcc does not play nice with them unless you add -U__BLOCKS__ 
 
Also since 10.6 defaults to 64-bit compilation you're going to have linking trouble as there is currently no libcudart.dylib that is 64-bit

You have to get it to compile a 32 bit app.  This usually involves setting -m32 on your compilation flags.  If you use CMake then I think you want this in an *empty* build directory.
 
CFLAGS=-m32
CXXFLAGS=-m32
cmake <path to source>

You might also have to add -U__BLOCKS__ to make the standard header files work.

Please let me know if any of this helps, or other questions.  I'd like to get OpenCurrent working on all platforms, so I'd like to figure this out & then update cmake and/or document it on the wiki page.

-Jon

s.layton

unread,
Feb 5, 2010, 11:30:35 AM2/5/10
to opencurrent-users
Thanks for all you help -- I can get a tiny bit further now -- those
nasty errors are gone, and I get a whole 1% further! My error is
below. For my cmake commands I've tried:

CFLAGS=-m32 CXXFLAGS=-m32 cmake ../src/

and

CFLAGS="-m32 -U__BLOCKS__" CXXFLAGS="-m32 -U__BLOCKS__" cmake ../src/

I'm not sure if thats where you intended the -U__BLOCKS__ to go
though..

Thanks again

-Simon

[ 9%] Building NVCC (Device) object ocustorage/./
ocustorage_generated_grid1ddev.cu.o
/Users/simon/mercurial/opencurrent/src/ocuutil/float_routines.h(37):
error: identifier "__finite" is undefined

1 error detected in the compilation of "/tmp/
tmpxft_00015459_00000000-4_grid1ddev.cpp1.ii".
CMake Error at ocustorage_generated_grid1ddev.cu.o.cmake:205


(message):
Error generating file
/Users/simon/mercurial/opencurrent/sm13_rel/ocustorage/./

ocustorage_generated_grid1ddev.cu.o


make[2]: *** [ocustorage/./ocustorage_generated_grid1ddev.cu.o] Error


1
make[1]: *** [ocustorage/CMakeFiles/ocustorage.dir/all] Error 2
make: *** [all] Error 2

On Feb 4, 5:02 pm, Jonathan Cohen <jco...@jcohen.name> wrote:
> Ok, I asked internally and there are some bumps with OSX 10.6 (is that what
> you're on?)  Here's what I found out:
>
> 10.6 introduced a bunch of crazy things, like their new GCD blocks
> mechanism, into a bunch of standard header files.  nvcc does not play nice
> with them unless you add -U__BLOCKS__
>
>  Also since 10.6 defaults to 64-bit compilation you're going to have linking
> trouble as there is currently no libcudart.dylib that is 64-bit
>
> You have to get it to compile a 32 bit app.  This usually involves setting
> -m32 on your compilation flags.  If you use CMake then I think you want this

> in an **empty** build directory.

Jonathan Cohen

unread,
Feb 5, 2010, 11:38:58 AM2/5/10
to opencurr...@googlegroups.com
Ah, ok, that's actually a problem in the source code, due to my not testing on OSX.

http://code.google.com/p/opencurrent/source/browse/src/ocuutil/float_routines.h#34

In the routine check_float(), it has different versions based on what compiler is being run, since cuda calls it '__finite', windows calls it '_finite', and everything else calls it 'finite'.  For some reason, '__finite' isn't working on OSX, even though it's being compiled through cuda.  If you look in the cuda include file 'math_functions.h' you can see that #ifdef __APPLE__ defines some other variations, like 'isfinite'.  So I suspect the correct thing to try is to add an #ifdef __APPLE__ to the check_float() implementations, and call something like isfinite() rather than __finite().

Let me know if you get it working.

Jon

s.layton

unread,
Feb 5, 2010, 12:15:19 PM2/5/10
to opencurrent-users
Ok, I got past that error: It was a hack but it worked for now:

I changed the __finite(f) call when CUDACC is defined to
__isfinitef(f) -- my preprocessing knowledge isn't good enough to
write a correct fix!

This is how far the compile is getting now:

-Simon

[ 29%] Built target ocustorage
[ 30%] Building NVCC (Device) object ocuequation/./
ocuequation_generated_sol_pcgpressure3d.cu.o
/usr/include/c++/4.2.1/ext/atomicity.h(51): error: identifier
"__sync_fetch_and_add" is undefined

/usr/include/c++/4.2.1/ext/atomicity.h(55): error: identifier
"__sync_fetch_and_add" is undefined

2 errors detected in the compilation of "/tmp/
tmpxft_00016ece_00000000-4_sol_pcgpressure3d.cpp1.ii".
CMake Error at ocuequation_generated_sol_pcgpressure3d.cu.o.cmake:205
(message):
Error generating file
/Users/simon/mercurial/opencurrent/sm14_rel/ocuequation/./
ocuequation_generated_sol_pcgpressure3d.cu.o


make[2]: *** [ocuequation/./
ocuequation_generated_sol_pcgpressure3d.cu.o] Error 1
make[1]: *** [ocuequation/CMakeFiles/ocuequation.dir/all] Error 2


make: *** [all] Error 2

On Feb 5, 11:38 am, Jonathan Cohen <jco...@jcohen.name> wrote:
> Ah, ok, that's actually a problem in the source code, due to my not testing
> on OSX.
>

> http://code.google.com/p/opencurrent/source/browse/src/ocuutil/float_...

Jonathan Cohen

unread,
Feb 5, 2010, 12:53:14 PM2/5/10
to opencurr...@googlegroups.com
Ugh.  I've seen this problem on linux with gcc 4.4, which is (currently) incompatible with CUDA.  But you're using gcc 4.2, which should work fine, except that OSX isn't the same as linux so all bets are off.

Just to make sure - you are using cuda 2.3?   Can you roll-back to gcc 4.1 and try that instead?  I'll ask around, and I'd suggest checking the cuda OSX forum I mentioned before.

-Jon

Jonathan Cohen

unread,
Feb 5, 2010, 12:56:04 PM2/5/10
to opencurr...@googlegroups.com
Actually, can you verify what version of gcc you are in fact using?  The include path is 4.2.1, but can you run 'gcc --version' just to check?

s.layton

unread,
Feb 5, 2010, 1:32:37 PM2/5/10
to opencurrent-users
I'm using gcc 4.2.1 and cuda 2.3.

I'm hitting up against a wall in that I can't seem to work out how to
use the gcc-4.0 includes -- even if I use the gcc-4.0 binary, it uses
the includes from 4.2.1


On Feb 5, 12:56 pm, Jonathan Cohen <jco...@jcohen.name> wrote:
> Actually, can you verify what version of gcc you are in fact using?  The
> include path is 4.2.1, but can you run 'gcc --version' just to check?
>
>
>
> On Fri, Feb 5, 2010 at 12:53 PM, Jonathan Cohen <jco...@jcohen.name> wrote:
> > Ugh.  I've seen this problem on linux with gcc 4.4, which is (currently)
> > incompatible with CUDA.  But you're using gcc 4.2, which should work fine,
> > except that OSX isn't the same as linux so all bets are off.
>
> > Just to make sure - you are using cuda 2.3?   Can you roll-back to gcc 4.1
> > and try that instead?  I'll ask around, and I'd suggest checking the cuda
> > OSX forum I mentioned before.
>
> > -Jon
>

s.layton

unread,
Feb 7, 2010, 6:26:01 PM2/7/10
to opencurrent-users
I've managed to get it all compiled now, sort of.

I installed gcc_select from macports, and set the default compiler to
4.0.0 -- this fixed the compile issues I was having above.

Currently, if I compile against sm13, it compiles fully, but does not
pass any non-netcdf tests (not surprising as as best I can tell I have
an sm11 capable card -- GeForce 9600M GT in an early 2009 Macbook
Pro). However, if I try to compile with sm11 (or sm12), I get the
errors below -- I assume this is something to do with sm11 having no
double support?

It seems so close to working now!

[ 69%] Building CXX object apps/CMakeFiles/pcg.dir/pcg.cpp.o
Linking CXX executable pcg
Undefined symbols:
"ocu::Sol_PCGPressure3DDevice<double>::solve(double&, double, int)",
referenced from:
compare_mg_pcg(int, int, int, double, double, double, double)in
pcg.cpp.o
run_pcg(int, int, int, double, double, double, double, double)in
pcg.cpp.o
compare_precond(int, int, int, double, double, double, double,
double)in pcg.cpp.o
compare_precond(int, int, int, double, double, double, double,
double)in pcg.cpp.o
"ocu::Sol_MultigridPressure3DDevice<double>::initialize_storage(int,
int, int, double, double, double, ocu::Grid3DDevice<double>*)",
referenced from:
init_mg_solver(ocu::Sol_MultigridPressure3DDevice<double>&,
ocu::Grid3DDevice<double>&, ocu::BoundaryConditionSet, int, int, int,
double, double, double)in pcg.cpp.o
"ocu::Sol_PCGPressure3DDevice<double>::initialize_storage(int, int,
int, float, float, float, ocu::Grid3DDevice<double>*,
ocu::Grid3DDevice<double>*)", referenced from:
init_pcg_solver(ocu::Sol_PCGPressure3DDevice<double>&,
ocu::Grid3DDevice<double>&, ocu::Grid3DDevice<double>&,
ocu::BoundaryConditionSet, int, int, int, float, float, float)in
pcg.cpp.o
"ocu::Sol_PCGPressure3DDevice<double>::Sol_PCGPressure3DDevice()",
referenced from:
compare_mg_pcg(int, int, int, double, double, double, double)in
pcg.cpp.o
run_pcg(int, int, int, double, double, double, double, double)in
pcg.cpp.o
compare_precond(int, int, int, double, double, double, double,
double)in pcg.cpp.o
compare_precond(int, int, int, double, double, double, double,
double)in pcg.cpp.o

"ocu::Sol_MultigridPressure3DDevice<double>::Sol_MultigridPressure3DDevice()",
referenced from:
compare_mg_pcg(int, int, int, double, double, double, double)in
pcg.cpp.o
run_mg(int, int, int, double, double, double, double)in
pcg.cpp.o
"ocu::Sol_PCGPressure3DDevice<double>::~Sol_PCGPressure3DDevice()",
referenced from:
compare_mg_pcg(int, int, int, double, double, double, double)in
pcg.cpp.o
compare_mg_pcg(int, int, int, double, double, double, double)in
pcg.cpp.o
run_pcg(int, int, int, double, double, double, double, double)in
pcg.cpp.o
run_pcg(int, int, int, double, double, double, double, double)in
pcg.cpp.o
compare_precond(int, int, int, double, double, double, double,
double)in pcg.cpp.o
compare_precond(int, int, int, double, double, double, double,
double)in pcg.cpp.o
compare_precond(int, int, int, double, double, double, double,
double)in pcg.cpp.o
compare_precond(int, int, int, double, double, double, double,
double)in pcg.cpp.o

"ocu::Sol_MultigridPressure3DDevice<double>::~Sol_MultigridPressure3DDevice()",
referenced from:
compare_mg_pcg(int, int, int, double, double, double, double)in
pcg.cpp.o
compare_mg_pcg(int, int, int, double, double, double, double)in
pcg.cpp.o
run_mg(int, int, int, double, double, double, double)in
pcg.cpp.o
run_mg(int, int, int, double, double, double, double)in
pcg.cpp.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [apps/pcg] Error 1
make[1]: *** [apps/CMakeFiles/pcg.dir/all] Error 2


make: *** [all] Error 2

Jonathan Cohen

unread,
Feb 7, 2010, 6:45:28 PM2/7/10
to opencurr...@googlegroups.com
Oh shoot, that's my fault. I'll post a fix tomorrow (watching the
superbowl now - go Saints!)

Jon

s.layton

unread,
Feb 7, 2010, 6:46:44 PM2/7/10
to opencurrent-users
Haha, that's what I'm doing now too! (However being English, I can't
really root for either team...)

On Feb 7, 6:45 pm, Jonathan Cohen <jco...@jcohen.name> wrote:
> Oh shoot, that's my fault. I'll post a fix tomorrow (watching the
> superbowl now - go Saints!)
>
> Jon
>

> > "ocu::Sol_MultigridPressure3DDevice<double>::Sol_MultigridPressure3DDevice( )",


> > referenced from:
> >       compare_mg_pcg(int, int, int, double, double, double, double)in
> > pcg.cpp.o
> >       run_mg(int, int, int, double, double, double, double)in
> > pcg.cpp.o
> >   "ocu::Sol_PCGPressure3DDevice<double>::~Sol_PCGPressure3DDevice()",
> > referenced from:
> >       compare_mg_pcg(int, int, int, double, double, double, double)in
> > pcg.cpp.o
> >       compare_mg_pcg(int, int, int, double, double, double, double)in
> > pcg.cpp.o
> >       run_pcg(int, int, int, double, double, double, double, double)in
> > pcg.cpp.o
> >       run_pcg(int, int, int, double, double, double, double, double)in
> > pcg.cpp.o
> >       compare_precond(int, int, int, double, double, double, double,
> > double)in pcg.cpp.o
> >       compare_precond(int, int, int, double, double, double, double,
> > double)in pcg.cpp.o
> >       compare_precond(int, int, int, double, double, double, double,
> > double)in pcg.cpp.o
> >       compare_precond(int, int, int, double, double, double, double,
> > double)in pcg.cpp.o
>

> > "ocu::Sol_MultigridPressure3DDevice<double>::~Sol_MultigridPressure3DDevice ()",

> ...
>
> read more »

s.layton

unread,
Feb 9, 2010, 10:54:59 AM2/9/10
to opencurrent-users
Ok, I'm still trying to get this going -- an attempt to make any of
the new revisions fails due to the need for gcc-4.2.x for openmp --
this causes the same errors found in my first post.

However, there where no updates to pcg.cpp, where the problem seems to
be occurring, so its unlikely this would have helped anyway!

Any ideas would as always be much appreciated!

-Simon

> ...
>
> read more »

Jonathan Cohen

unread,
Feb 9, 2010, 11:07:19 AM2/9/10
to opencurr...@googlegroups.com
Sorry, the big commit yesterday was unrelated to your issue.

I just committed a changeset that should fix compilation for non-sm_13.


http://code.google.com/p/opencurrent/source/detail?r=f517971fcbc602aa7f6fc18d1e14435c48234152

You might have to apply these changes manually, since the previous commit is unlikely to work on Mac, as you found out.

One thing on my todo list is to wrap all of the OpenMP-specific code inside some #ifdef's so it can be disabled on platforms without a working OpenMP compiler.  If you have any interest in helping with this, that would be great.

-Jon

Jonathan Cohen

unread,
Feb 12, 2010, 11:06:20 AM2/12/10
to opencurr...@googlegroups.com
Simon - another option is try try CUDA 3.0:

http://forums.nvidia.com/index.php?showtopic=149959

I haven't actually tried it with OpenCurrent yet, although it should work.  It should be compatible with more recent versions of gcc.

-Jon
Reply all
Reply to author
Forward
0 new messages