Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

cannot call std::sort with thrust::device_vector<T>::iterator #850

@andrewcorrigan

Description

@andrewcorrigan

This is related, but I think separate from #725. I cannot call std::sort using thrust::device_vector<T>::iterator. Compiling the below with AppleClang + libc++ I get the error message shown below, while compilation succeeds using AppleClang + libstdc++.

Reproducer:

#include <algorithm> 
#define THRUST_DEVICE_SYSTEM 4 // CPP 
#include <thrust/device_vector.h> 
int main(int argc, char** argv) 
{ 
    thrust::device_vector<int> a(10); 
    std::sort(a.begin(), a.end()); 
    return 0; 
}

Error message:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:3856:17: error: 
      no matching function for call to 'swap'
                swap(*__first, *__last);

where the relevant overload is

thrust/thrust/detail/device_reference.inl:49:6: note: 
      candidate function [with T = int] not viable: expects an l-value for 1st
      argument
void swap(device_reference<T> &a, device_reference<T> &b)

I tried adding overloads to thrust::swap, which instead accept either device_reference<T> or device_reference<T>&&, but then get the following error message. I'm just guessing at this point.

thrust/thrust/detail/reference.inl:196:3: error: 
      call to 'iter_swap' is ambiguous
  iter_swap(select_system(*system, *system), m_ptr, other.m_ptr); 

Metadata

Metadata

Assignees

Labels

nvbugHas an associated internal NVIDIA NVBug.to close: integrateNeeds integration, then can be closed.type: bug: functionalDoes not work as intended.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions