What is the location of output of thrust::reduce operation(GPU RAM or CPU RAM)? [duplicate]












0
















This question already has an answer here:




  • thrust reduction result on device memory

    2 answers




When we use thrust::reduce in the following example, the output is an int. Is this output (sum variable in code) located on the GPU or CPU RAM?



If it is in CPU RAM, how to access/retain the variable in the gpu?
The reduce operation happens on the device(GPU) so at some point the output should be in the GPU.



#include <thrust/reduce.h>
#include <thrust/execution_policy.h>
#include <thrust/device_vector.h>

int main()
{
thrust::device_vector<int> D(6);
D[0]=0;
D[1]=1;
D[2]=2;
D[3]=3;
D[4]=4;
D[5]=5;
int sum = thrust::reduce(thrust::device,D.begin(), D.end(), (int) 0, thrust::plus<int>());

}









share|improve this question













marked as duplicate by talonmies cuda
Users with the  cuda badge can single-handedly close cuda questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 16:47


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    Please check this answer by Robert Crovella

    – sgarizvi
    Nov 21 '18 at 10:44
















0
















This question already has an answer here:




  • thrust reduction result on device memory

    2 answers




When we use thrust::reduce in the following example, the output is an int. Is this output (sum variable in code) located on the GPU or CPU RAM?



If it is in CPU RAM, how to access/retain the variable in the gpu?
The reduce operation happens on the device(GPU) so at some point the output should be in the GPU.



#include <thrust/reduce.h>
#include <thrust/execution_policy.h>
#include <thrust/device_vector.h>

int main()
{
thrust::device_vector<int> D(6);
D[0]=0;
D[1]=1;
D[2]=2;
D[3]=3;
D[4]=4;
D[5]=5;
int sum = thrust::reduce(thrust::device,D.begin(), D.end(), (int) 0, thrust::plus<int>());

}









share|improve this question













marked as duplicate by talonmies cuda
Users with the  cuda badge can single-handedly close cuda questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 16:47


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    Please check this answer by Robert Crovella

    – sgarizvi
    Nov 21 '18 at 10:44














0












0








0









This question already has an answer here:




  • thrust reduction result on device memory

    2 answers




When we use thrust::reduce in the following example, the output is an int. Is this output (sum variable in code) located on the GPU or CPU RAM?



If it is in CPU RAM, how to access/retain the variable in the gpu?
The reduce operation happens on the device(GPU) so at some point the output should be in the GPU.



#include <thrust/reduce.h>
#include <thrust/execution_policy.h>
#include <thrust/device_vector.h>

int main()
{
thrust::device_vector<int> D(6);
D[0]=0;
D[1]=1;
D[2]=2;
D[3]=3;
D[4]=4;
D[5]=5;
int sum = thrust::reduce(thrust::device,D.begin(), D.end(), (int) 0, thrust::plus<int>());

}









share|improve this question















This question already has an answer here:




  • thrust reduction result on device memory

    2 answers




When we use thrust::reduce in the following example, the output is an int. Is this output (sum variable in code) located on the GPU or CPU RAM?



If it is in CPU RAM, how to access/retain the variable in the gpu?
The reduce operation happens on the device(GPU) so at some point the output should be in the GPU.



#include <thrust/reduce.h>
#include <thrust/execution_policy.h>
#include <thrust/device_vector.h>

int main()
{
thrust::device_vector<int> D(6);
D[0]=0;
D[1]=1;
D[2]=2;
D[3]=3;
D[4]=4;
D[5]=5;
int sum = thrust::reduce(thrust::device,D.begin(), D.end(), (int) 0, thrust::plus<int>());

}




This question already has an answer here:




  • thrust reduction result on device memory

    2 answers








cuda reduce ram thrust






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 10:10









user27665user27665

357415




357415




marked as duplicate by talonmies cuda
Users with the  cuda badge can single-handedly close cuda questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 16:47


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by talonmies cuda
Users with the  cuda badge can single-handedly close cuda questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 16:47


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1





    Please check this answer by Robert Crovella

    – sgarizvi
    Nov 21 '18 at 10:44














  • 1





    Please check this answer by Robert Crovella

    – sgarizvi
    Nov 21 '18 at 10:44








1




1





Please check this answer by Robert Crovella

– sgarizvi
Nov 21 '18 at 10:44





Please check this answer by Robert Crovella

– sgarizvi
Nov 21 '18 at 10:44












1 Answer
1






active

oldest

votes


















1














The result sum is on the CPU, you can refer to this documentation.



The result was probably at some point on the GPU, if the final result was computed on it. I didn't checked the implementation, but it could be possible that the final result is computed on the CPU. If you need to access it on the GPU, just pass it as a kernel argument, or copy it into global memory.






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    The result sum is on the CPU, you can refer to this documentation.



    The result was probably at some point on the GPU, if the final result was computed on it. I didn't checked the implementation, but it could be possible that the final result is computed on the CPU. If you need to access it on the GPU, just pass it as a kernel argument, or copy it into global memory.






    share|improve this answer




























      1














      The result sum is on the CPU, you can refer to this documentation.



      The result was probably at some point on the GPU, if the final result was computed on it. I didn't checked the implementation, but it could be possible that the final result is computed on the CPU. If you need to access it on the GPU, just pass it as a kernel argument, or copy it into global memory.






      share|improve this answer


























        1












        1








        1







        The result sum is on the CPU, you can refer to this documentation.



        The result was probably at some point on the GPU, if the final result was computed on it. I didn't checked the implementation, but it could be possible that the final result is computed on the CPU. If you need to access it on the GPU, just pass it as a kernel argument, or copy it into global memory.






        share|improve this answer













        The result sum is on the CPU, you can refer to this documentation.



        The result was probably at some point on the GPU, if the final result was computed on it. I didn't checked the implementation, but it could be possible that the final result is computed on the CPU. If you need to access it on the GPU, just pass it as a kernel argument, or copy it into global memory.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 10:43









        Robin ThoniRobin Thoni

        949718




        949718

















            這個網誌中的熱門文章

            Hercules Kyvelos

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud