Вектор упорного устройства не компилируется [дубликат]C++

Программы на C++. Форум разработчиков
Ответить
Гость
 Вектор упорного устройства не компилируется [дубликат]

Сообщение Гость »

Я пытаюсь изучить библиотеку Thrust на C++, чтобы научиться программированию на графическом процессоре, и я создал простой класс в заголовочном файле здесь:

Код: Выделить всё

#ifndef GRAPH
#define GRAPH

#include "Sine.h"
#include "CSV.h"
#include 
#include 

namespace graph {
class Graph {
public:
Graph(int resolution, writer::CSV& store);

void Place(producer::Sine pointproducer, int x, int y);
void Run(int epochs, int stepsize);
private:
std::vector
 producers;
std::vector positions;
thrust::device_vector grid; ------ Build started: Project: GPUelectromagneticsim, Configuration: Debug Win32 ------
1>GPUelectromagneticsim.cpp
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(87,42): error C2440: 'specialization': cannot convert from 'cudaError_t (__stdcall *)(void **,size_t)' to 'thrust::system::cuda::detail::allocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(87,42): message : None of the functions with this name in scope match the target type
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(87,54): error C2440: 'specialization': cannot convert from 'cudaError_t (__stdcall *)(void *)' to 'thrust::system::cuda::detail::deallocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(87,54): message : None of the functions with this name in scope match the target type
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(90,69): error C2440: 'specialization': cannot convert from 'cudaError_t (__stdcall *)(void *)' to 'thrust::system::cuda::detail::deallocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(90,69): message : None of the functions with this name in scope match the target type
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(93,42): error C2440: 'specialization': cannot convert from 'cudaError_t (__stdcall *)(void **,size_t)' to 'thrust::system::cuda::detail::allocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(93,42): message : None of the functions with this name in scope match the target type
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(93,58): error C2440: 'specialization': cannot convert from 'cudaError_t (__stdcall *)(void *)' to 'thrust::system::cuda::detail::deallocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(93,58): message : None of the functions with this name in scope match the target type
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(50): error C2440: 'specialization': cannot convert from 'int' to 'thrust::system::cuda::detail::allocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(50): message : Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(50): message : see reference to class template instantiation 'thrust::system::cuda::detail::cuda_memory_resource' being compiled
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\mr\validator.h(33): message : see reference to class template instantiation 'thrust::device_ptr_memory_resource' being compiled
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\mr\allocator.h(54): message : see reference to class template instantiation 'thrust::mr::validator' being compiled
1>        with
1>        [
1>            MR=thrust::device_ptr_memory_resource
1>         ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\mr\allocator.h(204): message : see reference to class template instantiation 'thrust::mr::allocator' being compiled
1>        with
1>        [
1>            T=float,
1>            Upstream=thrust::device_ptr_memory_resource
1>        ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(97): message : see reference to class template instantiation 'thrust::mr::stateless_resource_allocator' being compiled
1>        with
1>        [
1>            T=float
1>        ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\detail\allocator\allocator_traits.h(244): message : see reference to class template instantiation 'thrust::device_allocator' being compiled
1>        with
1>        [
1>            T=float
1>        ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\detail\contiguous_storage.h(41): message : see reference to class template instantiation 'thrust::detail::allocator_traits' being compiled
1>        with
1>        [
1>            Alloc=thrust::device_allocator
1>        ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\detail\vector_base.h(46): message : see reference to class template instantiation 'thrust::detail::contiguous_storage' being compiled
1>        with
1>        [
1>            T=float,
1>            Alloc=thrust::device_allocator
1>        ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_vector.h(55): message : see reference to class template instantiation 'thrust::detail::vector_base' being compiled
1>        with
1>        [
1>            T=float,
1>            Alloc=thrust::device_allocator
1>        ]
1>A:\GPUprac\GPUelectromagneticsim\GPUelectromagneticsim\Graph.h(19): message : see reference to class template instantiation 'thrust::device_vector' being compiled
1>        with
1>        [
1>            T=float
1>         ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(50,1): error C2973: 'thrust::system::cuda::detail::cuda_memory_resource': invalid template argument 'int'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(49): message : see declaration of 'thrust::system::cuda::detail::cuda_memory_resource'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(50): error C2440: 'specialization': cannot convert from 'int' to 'thrust::system::cuda::detail::deallocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(50): message : Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>A:\GPUprac\GPUelectromagneticsim\GPUelectromagneticsim\GPUelectromagneticsim.cpp(10,14): warning C4305: 'argument': truncation from 'double' to 'float'
1>A:\GPUprac\GPUelectromagneticsim\GPUelectromagneticsim\GPUelectromagneticsim.cpp(14,14): warning C4244: 'argument': conversion from 'double' to 'int', possible loss of data
1>Graph.cpp
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(87,42): error C2440: 'specialization': cannot convert from 'cudaError_t (__stdcall *)(void **,size_t)' to 'thrust::system::cuda::detail::allocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(87,42): message : None of the functions with this name in scope match the target type
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(87,54): error C2440: 'specialization': cannot convert from 'cudaError_t (__stdcall *)(void *)' to 'thrust::system::cuda::detail::deallocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(87,54): message : None of the functions with this name in scope match the target type
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(90,69): error C2440: 'specialization': cannot convert from 'cudaError_t (__stdcall *)(void *)' to 'thrust::system::cuda::detail::deallocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(90,69): message : None of the functions with this name in scope match the target type
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(93,42): error C2440: 'specialization': cannot convert from 'cudaError_t (__stdcall *)(void **,size_t)' to 'thrust::system::cuda::detail::allocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(93,42): message : None of the functions with this name in scope match the target type
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(93,58): error C2440: 'specialization': cannot convert from 'cudaError_t (__stdcall *)(void *)' to 'thrust::system::cuda::detail::deallocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(93,58): message : None of the functions with this name in scope match the target type
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(50): error C2440: 'specialization': cannot convert from 'int' to 'thrust::system::cuda::detail::allocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(50): message : Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(50): message : see reference to class template instantiation 'thrust::system::cuda::detail::cuda_memory_resource' being compiled
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\mr\validator.h(33): message : see reference to class template instantiation 'thrust::device_ptr_memory_resource' being compiled
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\mr\allocator.h(54): message : see reference to class template instantiation 'thrust::mr::validator' being compiled
1>        with
1>        [
1>            MR=thrust::device_ptr_memory_resource
1>         ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\mr\allocator.h(204): message : see reference to class template instantiation 'thrust::mr::allocator' being compiled
1>        with
1>        [
1>            T=float,
1>            Upstream=thrust::device_ptr_memory_resource
1>        ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(97): message : see reference to class template instantiation 'thrust::mr::stateless_resource_allocator' being compiled
1>        with
1>        [
1>            T=float
1>        ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\detail\allocator\allocator_traits.h(244): message : see reference to class template instantiation 'thrust::device_allocator' being compiled
1>        with
1>        [
1>            T=float
1>        ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\detail\contiguous_storage.h(41): message : see reference to class template instantiation 'thrust::detail::allocator_traits' being compiled
1>        with
1>        [
1>            Alloc=thrust::device_allocator
1>        ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\detail\vector_base.h(46): message : see reference to class template instantiation 'thrust::detail::contiguous_storage' being compiled
1>        with
1>        [
1>            T=float,
1>            Alloc=thrust::device_allocator
1>        ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_vector.h(55): message : see reference to class template instantiation 'thrust::detail::vector_base' being compiled
1>        with
1>        [
1>            T=float,
1>            Alloc=thrust::device_allocator
1>        ]
1>A:\GPUprac\GPUelectromagneticsim\GPUelectromagneticsim\Graph.h(19): message : see reference to class template instantiation 'thrust::device_vector' being compiled
1>        with
1>        [
1>            T=float
1>        ]
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(50,1): error C2973: 'thrust::system::cuda::detail::cuda_memory_resource': invalid template argument 'int'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\system\cuda\memory_resource.h(49): message : see declaration of 'thrust::system::cuda::detail::cuda_memory_resource'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(50): error C2440: 'specialization': cannot convert from 'int' to 'thrust::system::cuda::detail::deallocation_fn'
1>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include\thrust\device_allocator.h(50): message : Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>A:\GPUprac\GPUelectromagneticsim\GPUelectromagneticsim\Graph.cpp(24,20): warning C4244: '=': conversion from 'int' to 'float', possible loss of data
1>A:\GPUprac\GPUelectromagneticsim\GPUelectromagneticsim\Graph.cpp(28,4): warning C4018: '

Подробнее здесь: [url]https://stackoverflow.com/questions/78159728/thrust-device-vector-wont-compile[/url]
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»