headmyshoulder / odeint-v2

odeint - solving ordinary differential equations in c++ v2
http://headmyshoulder.github.com/odeint-v2/
Other
341 stars 101 forks source link

Odeint and Thrust/Cuda on Visual Studio 2010 #1

Closed johanseland closed 8 years ago

johanseland commented 12 years ago

Hello.

We are considering incorporating Odeint into our SPH solver which already uses Thrust and CUDA.

However, when we try to compile a minimal .cu file which just includes odeint.hpp, the result is that nvcc triggers an error in boost/typeof/msvc/typeof_impl.hpp (see belov for the the full error message).

This happens both with Boost 1.46 and 1.48 as well as with Cuda 4.0 and Cuda 4.1RC2

I can successfully use Odeint in regular cl.exe compiled source files in VS2010.

Has anyone else seen this?

Full error message: boost/typeof/msvc/typeof_impl.hpp(125): error : argument list for template "boost::type_of::msvc_extract_type<ID, T>::id2type_impl [with ID=ID, T=boost::type_of::msvc_extract_type_default_param]" is missing

mariomulansky commented 12 years ago

Hi,

thanks for your interest in odeint. Unfortunately, I can not test your configuration as we don't have a windows machine with CUDA available. We only used odeint with Linux and CUDA 3.2. However, you can try to make the example even more simplistic by including just boost/numeric/odeint/stepper/euler.hpp (the most simple stepper). Maybe that works and it would allow you to create a most basic test case of odeint on CUDA.

Regards, Mario

johanseland commented 12 years ago

Thanks for the prompt reply.

However, I do not need an easier sample. A one-line .cu-file with only the odeint.hpp include statement fails.

Actually, only including boost/numeric/odeint/util/ublas_wrapper.hpp is enough to trigger the error. I will try to dig a bit deeper into it and see if I can figure it out.

johanseland commented 12 years ago

Some further digging into this reveals that it is not odeint alone that is the problem. The bug is triggered by a one-liner .cu-file just including boost/numeric/ublas/vector.hpp

(My hunch is that is is really the boost::type_of::msvc_extract_type magic which is used by the above libraries that is the real problem.

I will try to forward this defect into the official Boost-bugtracker

headmyshoulder commented 12 years ago

Is SPH is surface particle hydrodynamics?

headmyshoulder commented 12 years ago

You can try to avoid include odeint.hpp. Include instead directly the header for your methods, like

include <boost/numeric/odeint/stepper/euler.hpp>

ublas is used by the implicit methods which are included in odeint.hpp

johanseland commented 12 years ago

SPH is smoothed particle hydrodynamics, so you almost got it right :)

I am now getting relaxation.cu and lorenz_parameter.cu to compile by defining BOOST_TYPEOF_COMPLIANT. This allows me to compile with Thrust using both the CUDA and the OpenMP backend.

However, both of the backends leads to runtime crashes somewhere in Thrust. I will see if I have some more time over the weekend to look into this.

mariomulansky commented 12 years ago

ok very good that you found out to get that working - useful information for us as well. The runtime crashes might be due to a bug on our side, I will look into to this today. I apologize for that because I think this is my bad.

mariomulansky commented 12 years ago

ok i just commited a bug fix for the thrust backend. We were applying some small changes to the memory management and I forgot to adjust the thrust backend. I hope this will fix your runtime crashes.

johanseland commented 12 years ago

Hi guys.

It does not seem like the resize-fix is enough.

When trying to run relaxation.cu I am now getting cudaErrorUnknown in synchronize.inl:synchronize:45. This is with Cuda 4.1rc2, I am not able to get it to compile with Cuda 4.0 on Windows.

Have you tried to 4.1 on Linux? (I only have access to 4.0 Linux machines, and there it runs without any problems.)

headmyshoulder commented 12 years ago

ok, i will try to test to compile and run it under linux with cude 4.1. this evening. at the moment i dont have access to a gpu machine.

headmyshoulder commented 12 years ago

Sry, i have no news about this issue. I will keep you informed...

headmyshoulder commented 12 years ago

I check all examples in odeint and It seems that they work with linux and cuda 4.0 and 4.1. CUDA_VERSION is 4010, so I guess the version is 4.1. Sorry, I don't have access to windows, to check what happends.

agerlach commented 12 years ago

I know this thread is old but has anybody found a solution to this since the last post 4 months ago? I need to do a parameter study and would love to use ODEINT with CUDA.

headmyshoulder commented 12 years ago

Are you using Windows or Linux? As far as I know there are no problems with Linux.

agerlach commented 12 years ago

I am using Windows 7 + VS2010. I installed Ubuntu as a dual boot and everything works fine there. I realize from your other replies that you don't have access to a windows machine to test this behavior, but I wondered if the person asking the problem ever found a work around. From some other forums I read it seems to be a problem with nvcc not properly handling boost. Hence the "boost::type_of::msvc_extract_type" error johanseland was getting. Boost is checking the msvc version but generates an error since nvcc is actually calling it.

I'm a novice at all this so take my comments with a grain of salt. For the mean time I will try to use linux although I need my code to interface with Matlab and one of the Matlab tookboxes I need only runs on window.

mariomulansky commented 12 years ago

As said, we can't test nvcc on windows. i'm sorry for that but we just don't have a windows cuda machine accessible. I believe that johanseland was able to circumvent this problem by not using thrust but implementing their own backends. I dont know how exactly this works but i think if you can separate the cuda calls in a single cu file and just compile that with nvcc and then link it against your program which uses odeint you might be able to get things working. This is just an idea and I'm not sure it works and it might be quite ugly to implement. Moreover, I think the problem is not related to odeint but rather to some of the boost libraries we are using. if you can nail the problem down precisely maybe we can try to get odeint not using this library when compiled with nvcc.

GBZH commented 12 years ago

Last week I have downloaded odeint and would like to use it on a GPU computing system: Linux Ubuntu 12.04 LTS and deviceQuery giving CUDA Driver = CUDART, CUDA Driver Version = 5.0, CUDA Runtime Version = 4.2 (also installed last week), NumDevs = 2, Device = Tesla C2050, Device = Tesla C2050.

But when I try to compile examples given in the odieint distribution, I get the same type as error mentioned in previous posts as shown below:

~/local/odeint-v2/libs/numeric/odeint/examples/thrust$ make relaxation /usr/local/cuda/bin/nvcc -O3 -I -I -I/usr/local/cuda/include -I../../../../.. -arch sm_20 --compiler-bindir=/usr/bin/g++ -Xcompiler -fopenmp -DTHRUST_DEVICE_BACKEND=THRUST_DEVICE_BACKEND_OMP -c relaxation.cu -o relaxation.co ../../../../../boost/numeric/odeint/util/unit_helper.hpp(134): error: name followed by "::" must be a class or namespace name

../../../../../boost/numeric/odeint/util/unit_helper.hpp(134): error: too many arguments for class template "boost::numeric::odeint::inverse_time"

../../../../../boost/numeric/odeint/util/unit_helper.hpp(142): warning: parsing restarts here after previous syntax error

2 errors detected in the compilation of "/tmp/tmpxft_00001a98_00000000-4_relaxation.cpp1.ii". make: *\ [relaxation.co] Erreur 2

Does anyone know a solution ? Thanks

mariomulansky commented 12 years ago

Your error is unrelated to the original problem in this thread. It is due to a bug we introduced in the unit_helper.hpp. I've made a fix just now and if you update to the latest version of the library this should disappear. If not, please open a new issue.

Thanks for providing feedback.