The "Rapid Problem-Solving Using Thrust" example question

Hi guys, I am studying “Rapid Problem-Solving Using Thrust”[1] in GTC,
and now I have some questions about the last example rainfall
measurements.

if we have the SoAs like below:
day {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4}
site {1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4}
measurement {2,1,3,4,6,3,3,6,7,3,2,5,7,3,5,8,6,4,2,5}

my question is: if I want to sum rainfall measurement in all days and
just in site 2 and 4, how should I do best?
I mean I know how to use a loop to sum measurements in days by pass a
site paramter,like the Example “Total Rainfall at a Given Site”. But I
am looking for a better way in Thrust

Thanks guys!

[1]http://www.gputechconf.com/object/gtc-express-webinar.html

need help!!

That IS the best way. Simply compare with both 2 and 4 in the functor.

sorry I dont think so guy. It is a very simple sum and maybe transporting data between host and device takes a much long time.

so I need a best way to avoid that.

What data transport are you talking about exactly? This approach would only transfer the functor as a parameter to the device and the final reduction result back.

you could use the existing sample for one site and expand it for two sites.

return a tuple<int, int> for the first and second site.

if you want it more dynamic with N sites, this might be a problem with thrust. or you prototype the code for all tuple-types and choose the right path at runtime (note: code must be generated for all numbers of sites at compile time)