Skip to content

'J': is not a valid type for non-type template parameter 'J' error in boost\fusion\container\vector\vector.hpp #269

@DanielMueller1996

Description

@DanielMueller1996

I am using Visual Studio 2022 and am currently trying to compile the following code:

#include <iostream>
#include <cmath>

#include <thrust/device_vector.h>
#include <thrust/iterator/permutation_iterator.h>
#include <thrust/iterator/counting_iterator.h>

#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
#include <boost/numeric/odeint/integrate/integrate_const.hpp>
#include <boost/numeric/odeint/external/thrust/thrust.hpp>

using namespace std;

using namespace boost::numeric::odeint;


//change this to float if your device does not support double computation
typedef double value_type;


//[ thrust_phase_chain_system
//change this to host_vector< ... > if you want to run on CPU
typedef thrust::device_vector< value_type > state_type;
typedef thrust::device_vector< size_t > index_vector_type;
//typedef thrust::host_vector< value_type > state_type;
//typedef thrust::host_vector< size_t > index_vector_type;


class phase_oscillators
{

public:

    struct sys_functor
    {
        template< class Tuple >
        __host__ __device__
            void operator()(Tuple t)  // this functor works on tuples of values
        {
            // first, unpack the tuple into value, neighbors and omega
            const value_type phi = thrust::get<0>(t);
            const value_type phi_left = thrust::get<1>(t);  // left neighbor
            const value_type phi_right = thrust::get<2>(t); // right neighbor
            const value_type omega = thrust::get<3>(t);
            // the dynamical equation
            thrust::get<4>(t) = omega + sin(phi_right - phi) + sin(phi - phi_left);
        }
    };

    phase_oscillators(const state_type& omega)
        : m_omega(omega), m_N(omega.size()), m_prev(omega.size()), m_next(omega.size())
    {
        // build indices pointing to left and right neighbours
        thrust::counting_iterator<size_t> c(0);
        thrust::copy(c, c + m_N - 1, m_prev.begin() + 1);
        m_prev[0] = 0; // m_prev = { 0 , 0 , 1 , 2 , 3 , ... , N-1 }

        thrust::copy(c + 1, c + m_N, m_next.begin());
        m_next[m_N - 1] = m_N - 1; // m_next = { 1 , 2 , 3 , ... , N-1 , N-1 }
    }

    void operator() (const state_type& x, state_type& dxdt, const value_type dt)
    {
        thrust::for_each(
            thrust::make_zip_iterator(
                thrust::make_tuple(
                    x.begin(),
                    thrust::make_permutation_iterator(x.begin(), m_prev.begin()),
                    thrust::make_permutation_iterator(x.begin(), m_next.begin()),
                    m_omega.begin(),
                    dxdt.begin()
                )),
            thrust::make_zip_iterator(
                thrust::make_tuple(
                    x.end(),
                    thrust::make_permutation_iterator(x.begin(), m_prev.end()),
                    thrust::make_permutation_iterator(x.begin(), m_next.end()),
                    m_omega.end(),
                    dxdt.end())),
            sys_functor()
        );
    }

private:

    const state_type& m_omega;
    const size_t m_N;
    index_vector_type m_prev;
    index_vector_type m_next;
};
//]

const size_t N = 32768;
const value_type pi = 3.1415926535897932384626433832795029;
const value_type epsilon = 6.0 / (N * N); // should be < 8/N^2 to see phase locking
const value_type dt = 0.1;

int main(int arc, char* argv[])
{
    //[ thrust_phase_chain_integration
    // create initial conditions and omegas on host:
    vector< value_type > x_host(N);
    vector< value_type > omega_host(N);
    for (size_t i = 0; i < N; ++i)
    {
        x_host[i] = 2.0 * pi * rand();
        omega_host[i] = (N - i) * epsilon; // decreasing frequencies
    }

    // copy to device
    state_type x = x_host;
    state_type omega = omega_host;

    // create stepper
    runge_kutta4< state_type, value_type, state_type, value_type > stepper;

    // create phase oscillator system function
    phase_oscillators sys(omega);

    // integrate
    integrate_const(stepper, sys, x, 0.0, 10.0, dt);

    thrust::copy(x.begin(), x.end(), std::ostream_iterator< value_type >(std::cout, "\n"));
    std::cout << std::endl;
    //]
}

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:

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2993	'J': is not a valid type for non-type template parameter 'J'	Pairproduction	C:\Program Files\Boost\boost_1_81_0\boost\fusion\container\vector\vector.hpp	236	
Error	C2062	type 'unknown-type' unexpected	Pairproduction	C:\Program Files\Boost\boost_1_81_0\boost\fusion\container\vector\vector.hpp	236	
Error	C2334	unexpected token(s) preceding '{'; skipping apparent function body	Pairproduction	C:\Program Files\Boost\boost_1_81_0\boost\fusion\container\vector\vector.hpp	239	
Error	C2993	'J': is not a valid type for non-type template parameter 'J'	Pairproduction	C:\Program Files\Boost\boost_1_81_0\boost\fusion\container\vector\vector.hpp	243	
Error	C4430	missing type specifier - int assumed. Note: C++ does not support default-int	Pairproduction	C:\Program Files\Boost\boost_1_81_0\boost\fusion\container\vector\vector.hpp	243	
Error	C2062	type 'unknown-type' unexpected	Pairproduction	C:\Program Files\Boost\boost_1_81_0\boost\fusion\container\vector\vector.hpp	243	
Error	C2334	unexpected token(s) preceding '{'; skipping apparent function body	Pairproduction	C:\Program Files\Boost\boost_1_81_0\boost\fusion\container\vector\vector.hpp	246	
Error	C2504	'boost::fusion::vector_detail::vector_data<std::integer_sequence<unsigned __int64,0,1,2,3>,boost::numeric::odeint::detail::stage<T,1>,boost::numeric::odeint::detail::stage<T,2>,boost::numeric::odeint::detail::stage<T,3>,boost::numeric::odeint::detail::stage<T,4>>': base class undefined	Pairproduction	C:\Program Files\Boost\boost_1_81_0\boost\fusion\container\vector\vector.hpp	253	
Error	MSB3721	The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.0\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env -ccbin "G:\Visual Studio\VC\Tools\MSVC\14.34.31933\bin\HostX64\x64" -x cu   -I"C:\Program Files\Boost\boost_1_81_0" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.0\include"  -G   --keep-dir x64\Debug  -maxrregcount=0  --machine 64 --compile -cudart static  -g  -DWIN32 -DWIN64 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Fdx64\Debug\vc143.pdb /FS /Zi /RTC1 /MDd " -o "C:\Users\danie\OneDrive\Dokumente\schule\studium\7. Semester\Spezialisierung\Spezialisierung_code\Pairproduction\x64\Debug\kernel.cu.obj" "C:\Users\danie\OneDrive\Dokumente\schule\studium\7. Semester\Spezialisierung\Spezialisierung_code\Pairproduction\kernel.cu"" exited with code 2.	Pairproduction	G:\Visual Studio\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 12.0.targets	794

What is wrong and can i fix it on my end?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions