Open derdotte opened 1 year ago
I've tried such a method: correct the code in "boost\fusion\container\vector\vector.hpp"
private:
template
public:
template
template <std::size_t J>
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
typename store_at<J>::elem_type const& at_impl(std::integral_constant<std::size_t, J>) const
{
return store_at<J>::elem;
}
};
NOTICE: I don't know whether such a method will have an influence on other libraries
If you think this is a fusion issue, please post an MVCE (without any dependencies). I have no expertise on the other dependent libraries.
Has this issue been solved?
Has this issue been solved?
Again, please post an MVCE https://stackoverflow.com/help/minimal-reproducible-example
Hello, I have been facing the same issue then I am going to include a MVCE using a .cu file:
Configurations: -Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.11.0 -Nvidia Driver Version: 560.81 -CUDA Toolkit 12.6 -BOOST 1.86 -MVCE.cu
MVCE.cu:
#include <boost/numeric/odeint.hpp>
int main()
{
}
Output:
2.Error C2993 'J': is not a valid type for non-type template parameter 'J' CudaRuntime1 C:\Users\benny\Downloads\boost_1_86_0\boost\fusion\container\vector\vector.hpp 236
Error C2062 type 'unknown-type' unexpected CudaRuntime1 C:\Users\benny\Downloads\boost_1_86_0\boost\fusion\container\vector\vector.hpp 236
Error C2334 unexpected token(s) preceding '{'; skipping apparent function body CudaRuntime1 C:\Users\benny\Downloads\boost_1_86_0\boost\fusion\container\vector\vector.hpp 239
5.Error C2993 'J': is not a valid type for non-type template parameter 'J' CudaRuntime1 C:\Users\benny\Downloads\boost_1_86_0\boost\fusion\container\vector\vector.hpp 243
6.Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int CudaRuntime1 C:\Users\benny\Downloads\boost_1_86_0\boost\fusion\container\vector\vector.hpp 243
7.Error C2062 type 'unknown-type' unexpected CudaRuntime1 C:\Users\benny\Downloads\boost_1_86_0\boost\fusion\container\vector\vector.hpp 243
The first error refers to the use of a C++ version prior to C++ 20 but I have used C++ 20 and it is the same error.
On the other hand, if it is replaced odeint by interval then the code compiles properly.
#include <boost/numeric/odeint.hpp>
int main()
{
}
Output: ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== ========== Build completed at 11:07 AM and took 01.917 seconds ==========
Finally, this code works properly in Ubuntu using CMake then it is not a general incompatibility between CUDA and BOOST. I hope you can help us with this issue. Thank you so much in advance! Let me know if there is something I can do to help you to fix this error.
include <boost/numeric/odeint.hpp>
This is not directly a Boost.Fusion issue, and should probably be redirected to Boost.Numeric.Odeint instead.
Hello: On Windows 11, I have found that if you comment out these lines from vector.hpp the code works properly. In my case, I am using the Boost library in the host then I do not need anything in the device. Definitely, there are some differences in how vector.hpp is treated on Windows and Ubuntu.
Code using C++ compiler:
#include <boost/numeric/odeint.hpp>
#include <iostream>
#include <vector>
using namespace boost::numeric::odeint;
std::vector<std::vector<double>> variable;
std::vector<double> times;
void system_of_equations(const std::vector<double>& variables,
std::vector<double>& derivative_rates, const double time)
{
derivative_rates[0] = variables[0] + variables[1];
derivative_rates[1] = variables[0] - variables[1];
}
void printVariables(const std::vector<double>& variables, const double time)
{
std::cout << "t=" << time << " "
<< "x=" << variables[0] << " "
<< "y=" << variables[1] << std::endl;
variable.push_back(variables);
times.push_back(time);
}
int main()
{
std::vector<double> initial_variables = { 1.0, 0.0 };
double start_time = 0.0, end_time = 5,
time_step = 1e-4;
integrate(system_of_equations, initial_variables, start_time, end_time, time_step, printVariables);
return 0;
}
Output:
t=0 x=1 y=0
t=0.0001 x=1.0001 y=0.0001
t=0.00055 x=1.00055 y=0.00055
t=0.002575 x=1.00258 y=0.00257501
t=0.0116875 x=1.01182 y=0.011688
t=0.0526938 x=1.05552 y=0.0527425
t=0.23332 x=1.29251 y=0.237577
t=0.413945 x=1.6143 y=0.437997
t=0.605022 x=2.07053 y=0.681595
t=0.796099 x=2.67888 y=0.975267
t=0.987176 x=3.48403 y=1.34059
t=1.17825 x=4.54515 y=1.8044
t=1.36933 x=5.94017 y=2.40077
t=1.56041 x=7.7716 y=3.17352
t=1.75148 x=10.174 y=4.17941
t=1.94256 x=13.3238 y=5.49234
t=2.13364 x=17.4525 y=7.20878
t=2.32471 x=22.8633 y=9.45482
t=2.51579 x=29.9538 y=12.3955
t=2.70687 x=39.2449 y=16.2468
t=2.89794 x=51.4192 y=21.2916
t=3.08902 x=67.371 y=27.9007
t=3.2801 x=88.2723 y=36.5596
t=3.47117 x=115.659 y=47.9043
t=3.66225 x=151.542 y=62.7684
t=3.85333 x=198.558 y=82.2438
t=4.0444 x=260.162 y=107.761
t=4.23548 x=340.879 y=141.196
t=4.42656 x=446.639 y=185.003
t=4.61763 x=585.212 y=242.402
t=4.80871 x=766.778 y=317.609
t=4.99979 x=1004.68 y=416.15
t=5 x=1004.98 y=416.276
Code using C++ and NVCC:
#include<cuda_runtime.h>
#include<stdio.h>
#include <boost/numeric/odeint.hpp>
#include <iostream>
#include <vector>
using namespace boost::numeric::odeint;
std::vector<std::vector<double>> variable;
std::vector<double> times;
void system_of_equations(const std::vector<double>& variables,
std::vector<double>& derivative_rates, const double time)
{
derivative_rates[0] = variables[0] + variables[1];
derivative_rates[1] = variables[0] - variables[1];
}
void printVariables(const std::vector<double>& variables, const double time)
{
std::cout << "t=" << time << " "
<< "x=" << variables[0] << " "
<< "y=" << variables[1] << std::endl;
variable.push_back(variables);
times.push_back(time);
}
__global__ void hello()
{
printf("Hello World!\n");
}
int main()
{
std::vector<double> initial_variables = { 1.0, 0.0 };
double start_time = 0.0, end_time = 5,
time_step = 1e-4;
integrate(system_of_equations, initial_variables, start_time, end_time, time_step, printVariables);
int* a;
cudaMalloc(&a, 10 * sizeof(int));
cudaFree(a);
hello << <1, 10 >> > ();
cudaDeviceReset();
return 0;
}
Output:
t=0 x=1 y=0
t=0.0001 x=1.0001 y=0.0001
t=0.00055 x=1.00055 y=0.00055
t=0.002575 x=1.00258 y=0.00257501
t=0.0116875 x=1.01182 y=0.011688
t=0.0526938 x=1.05552 y=0.0527425
t=0.23332 x=1.29251 y=0.237577
t=0.413945 x=1.6143 y=0.437997
t=0.605022 x=2.07053 y=0.681595
t=0.796099 x=2.67888 y=0.975267
t=0.987176 x=3.48403 y=1.34059
t=1.17825 x=4.54515 y=1.8044
t=1.36933 x=5.94017 y=2.40077
t=1.56041 x=7.7716 y=3.17352
t=1.75148 x=10.174 y=4.17941
t=1.94256 x=13.3238 y=5.49234
t=2.13364 x=17.4525 y=7.20878
t=2.32471 x=22.8633 y=9.45482
t=2.51579 x=29.9538 y=12.3955
t=2.70687 x=39.2449 y=16.2468
t=2.89794 x=51.4192 y=21.2916
t=3.08902 x=67.371 y=27.9007
t=3.2801 x=88.2723 y=36.5596
t=3.47117 x=115.659 y=47.9043
t=3.66225 x=151.542 y=62.7684
t=3.85333 x=198.558 y=82.2438
t=4.0444 x=260.162 y=107.761
t=4.23548 x=340.879 y=141.196
t=4.42656 x=446.639 y=185.003
t=4.61763 x=585.212 y=242.402
t=4.80871 x=766.778 y=317.609
t=4.99979 x=1004.68 y=416.15
t=5 x=1004.98 y=416.276
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
I am using Visual Studio 2022 and am currently trying to compile the following code:
An error occurs upon compilation using VS22 community edition in
vector.hpp
.Boost Version: 1.81 Platform: Windows 10 64x
This uses Thrust functionality to calculate a large amount of ODEs.
The error is:
What is wrong and can i fix it on my end?