@@ -95,20 +95,16 @@ int main()
9595 heterogeneous_key_equal{},
9696 cuco::linear_probing<1 , heterogeneous_hasher>{heterogeneous_hasher{}}};
9797
98- // Host data describing the sensor readings we want to store using cuco::pair keys.
99- thrust::host_vector<stored_key> h_keys{
98+ thrust::device_vector<stored_key> d_keys = {
10099 stored_key{101 , 3 },
101100 stored_key{104 , 8 },
102101 stored_key{215 , 1 },
103102 stored_key{305 , 0 },
104103 };
105- thrust::host_vector<value_type> h_values{36 .5f , 41 .2f , 27 .1f , 33 .8f };
106-
107- thrust::device_vector<stored_key> d_keys = h_keys;
108- thrust::device_vector<value_type> d_values = h_values;
104+ thrust::device_vector<value_type> d_values = {36 .5f , 41 .2f , 27 .1f , 33 .8f };
109105
110106 auto pairs_begin = thrust::make_transform_iterator (
111- thrust::make_counting_iterator< int >( 0 ) ,
107+ thrust::counting_iterator{ 0 } ,
112108 cuda::proclaim_return_type<cuco::pair<stored_key, value_type>>(
113109 [keys = d_keys.begin (), values = d_values.begin ()] __device__ (int i) {
114110 return cuco::pair<stored_key, value_type>{keys[i], values[i]};
@@ -119,22 +115,22 @@ int main()
119115 // Query using 3-element tuples that include an additional timestamp field.
120116 // The heterogeneous hash and equality functors only consider the first two components
121117 // (sensor_id, channel) when comparing against the stored cuco::pair keys.
122- thrust::host_vector <probe_key> h_queries {
118+ thrust::device_vector <probe_key> d_queries {
123119 probe_key{101 , 3 , 1210 }, // present in the map
124120 probe_key{215 , 1 , 1345 }, // present in the map
125121 probe_key{999 , 4 , 2000 }, // missing entry
126122 };
127123
128- thrust::device_vector<probe_key> d_queries = h_queries;
129-
130- thrust::device_vector<bool > d_contains (h_queries.size ());
124+ thrust::device_vector<bool > d_contains (d_queries.size ());
131125 map.contains (d_queries.begin (), d_queries.end (), d_contains.begin ());
132126
133- thrust::device_vector<value_type> d_found (h_queries .size ());
127+ thrust::device_vector<value_type> d_found (d_queries .size ());
134128 map.find (d_queries.begin (), d_queries.end (), d_found.begin ());
135129
136- thrust::host_vector<bool > h_contains = d_contains;
137- thrust::host_vector<value_type> h_found = d_found;
130+ // Copy results back to host for printing
131+ thrust::host_vector<probe_key> h_queries = d_queries;
132+ thrust::host_vector<bool > h_contains = d_contains;
133+ thrust::host_vector<value_type> h_found = d_found;
138134
139135 for (std::size_t i = 0 ; i < h_queries.size (); ++i) {
140136 auto const & query = h_queries[i];
0 commit comments