Giter Site home page Giter Site logo

Comments (5)

pauleonix avatar pauleonix commented on July 28, 2024 1

If possibe, I would rather just use the right constructor to avoid unnecessary initialisation, i.e.

thrust::device_vector<float> d_c(d_b.cbegin() + 80, d_b.cend());
// or
thrust::device_vector<float> d_c(d_b.cbegin() + 80, d_b.cbegin() + 100);

from thrust.

miscco avatar miscco commented on July 28, 2024

I am not fully sure what you mean with d_b[80:100]

However, you could always use one of the algorithms such like https://github.com/NVIDIA/thrust/blob/main/thrust/fill.h

from thrust.

ztdepztdep avatar ztdepztdep commented on July 28, 2024

I am not fully sure what you mean with d_b[80:100]

However, you could always use one of the algorithms such like https://github.com/NVIDIA/thrust/blob/main/thrust/fill.h

I mean fill thrust vector with d_b from the 80'th to the 100'th values.

from thrust.

miscco avatar miscco commented on July 28, 2024

In that case you would need to use thrust::copy or thrust::copy_n You can find some documentation here

thrust/thrust/copy.h

Lines 118 to 130 in 125d281

* \code
* #include <thrust/copy.h>
* #include <thrust/device_vector.h>
* #include <thrust/execution_policy.h>
* ...
* size_t n = 100;
* thrust::device_vector<int> vec0(n);
* thrust::device_vector<int> vec1(n);
* ...
* thrust::copy_n(thrust::device, vec0.begin(), n, vec1.begin());
*
* // vec1 is now a copy of vec0
* \endcode

from thrust.

Pavelevich avatar Pavelevich commented on July 28, 2024

this can work for u:

  • device vector is already with some values

int main()
{
int size = 299;
int d_b[299];
thrust::device_vector d(d_b, d_b + size);
thrust::device_ptr d_ptr = thrust::make_device_ptr(d_b);
thrust::device_vector d_subset(d_ptr + 66, d_ptr + 299);
return 0;
}

from thrust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.