154 Kokkos::View<
offset_t*, Kokkos::Device<ExecutionSpace,MemorySpace>> dist_offsets,
155 Kokkos::View<
lno_t*, Kokkos::Device<ExecutionSpace, MemorySpace>> dist_adjs,
156 Kokkos::View<
int*, Kokkos::Device<ExecutionSpace, MemorySpace>> femv_colors,
157 Kokkos::View<
lno_t*, Kokkos::Device<ExecutionSpace, MemorySpace>> boundary_verts_view,
159 Kokkos::Device<ExecutionSpace, MemorySpace> > verts_to_recolor_view,
161 Kokkos::Device<ExecutionSpace, MemorySpace>,
162 Kokkos::MemoryTraits<Kokkos::Atomic> > verts_to_recolor_size_atomic,
164 Kokkos::Device<ExecutionSpace, MemorySpace> > verts_to_send_view,
165 Kokkos::View<
size_t*,
166 Kokkos::Device<ExecutionSpace, MemorySpace>,
167 Kokkos::MemoryTraits<Kokkos::Atomic> > verts_to_send_size_atomic,
168 Kokkos::View<
size_t*, Kokkos::Device<ExecutionSpace, MemorySpace>> recoloringSize,
169 Kokkos::View<
int*, Kokkos::Device<ExecutionSpace, MemorySpace>> rand,
170 Kokkos::View<
gno_t*, Kokkos::Device<ExecutionSpace, MemorySpace>> gid,
171 Kokkos::View<
gno_t*, Kokkos::Device<ExecutionSpace, MemorySpace>> ghost_degrees,
172 bool recolor_degrees){
173 Kokkos::RangePolicy<ExecutionSpace> policy(0, boundary_verts_view.extent(0));
174 size_t local_recoloring_size;
175 Kokkos::parallel_reduce(
"D2 conflict detection",policy, KOKKOS_LAMBDA(
const uint64_t& i,
size_t& recoloring_size){
177 const size_t curr_lid = boundary_verts_view(i);
178 const int curr_color = femv_colors(curr_lid);
179 const size_t vid_d1_adj_begin = dist_offsets(curr_lid);
180 const size_t vid_d1_adj_end = dist_offsets(curr_lid+1);
181 const size_t curr_degree = vid_d1_adj_end - vid_d1_adj_begin;
182 for(
size_t vid_d1_adj = vid_d1_adj_begin; vid_d1_adj < vid_d1_adj_end; vid_d1_adj++){
184 size_t vid_d1 = dist_adjs(vid_d1_adj);
185 size_t vid_d1_degree = 0;
187 if(vid_d1 < n_local){
188 vid_d1_degree = dist_offsets(vid_d1+1) - dist_offsets(vid_d1);
190 vid_d1_degree = ghost_degrees(vid_d1-n_local);
192 if( vid_d1 != curr_lid && femv_colors(vid_d1) == curr_color){
193 if(curr_degree < vid_d1_degree && recolor_degrees){
194 femv_colors(curr_lid) = 0;
197 }
else if (vid_d1_degree < curr_degree && recolor_degrees){
198 femv_colors(vid_d1) = 0;
200 }
else if(rand(curr_lid) < rand(vid_d1)){
201 femv_colors(curr_lid) = 0;
204 }
else if(rand(vid_d1) < rand(curr_lid)){
205 femv_colors(vid_d1) = 0;
208 if(gid(curr_lid) >= gid(vid_d1)){
209 femv_colors(curr_lid) = 0;
213 femv_colors(vid_d1) = 0;
218 size_t d2_adj_begin = 0;
219 size_t d2_adj_end = 0;
220 d2_adj_begin = dist_offsets(vid_d1);
221 d2_adj_end = dist_offsets(vid_d1+1);
227 for(
size_t vid_d2_adj = d2_adj_begin; vid_d2_adj < d2_adj_end; vid_d2_adj++){
229 const size_t vid_d2 = dist_adjs(vid_d2_adj);
230 size_t vid_d2_degree = 0;
232 if(vid_d2 < n_local){
233 vid_d2_degree = dist_offsets(vid_d2+1) - dist_offsets(vid_d2);
235 vid_d2_degree = ghost_degrees(vid_d2-n_local);
237 if(curr_lid != vid_d2 && femv_colors(vid_d2) == curr_color){
238 if(curr_degree < vid_d2_degree && recolor_degrees){
240 femv_colors(curr_lid) = 0;
243 }
else if(vid_d2_degree < curr_degree && recolor_degrees){
244 femv_colors(vid_d2) = 0;
246 }
else if(rand(curr_lid) < rand(vid_d2)){
248 femv_colors(curr_lid) = 0;
251 }
else if(rand(vid_d2) < rand(curr_lid)){
252 femv_colors(vid_d2) = 0;
255 if(gid(curr_lid) >= gid(vid_d2)){
257 femv_colors(curr_lid) = 0;
261 femv_colors(vid_d2) = 0;
269 },local_recoloring_size);
270 Kokkos::deep_copy(recoloringSize,local_recoloring_size);
274 Kokkos::parallel_for(
"rebuild verts_to_send and verts_to_recolor",
275 Kokkos::RangePolicy<ExecutionSpace>(0,femv_colors.size()),
276 KOKKOS_LAMBDA(
const uint64_t& i){
277 if(femv_colors(i) == 0){
280 verts_to_send_view(verts_to_send_size_atomic(0)++) = i;
283 verts_to_recolor_view(verts_to_recolor_size_atomic(0)++) = i;
292 Kokkos::View<offset_t*, device_type > dist_offsets_dev,
293 Kokkos::View<lno_t*, device_type > dist_adjs_dev,
294 Kokkos::View<int*,device_type > femv_colors,
295 Kokkos::View<lno_t*, device_type > boundary_verts_view,
300 Kokkos::MemoryTraits<Kokkos::Atomic>> verts_to_recolor_size_atomic,
303 Kokkos::View<
size_t*,
305 Kokkos::MemoryTraits<Kokkos::Atomic>> verts_to_send_size_atomic,
306 Kokkos::View<size_t*, device_type> recoloringSize,
313 bool recolor_degrees){
315 this->detectD2Conflicts<execution_space, memory_space>(n_local,
320 verts_to_recolor_view,
321 verts_to_recolor_size_atomic,
323 verts_to_send_size_atomic,
332 typename Kokkos::View<offset_t*, device_type >::host_mirror_type dist_offsets_host,
333 typename Kokkos::View<lno_t*, device_type >::host_mirror_type dist_adjs_host,
334 typename Kokkos::View<int*,device_type >::host_mirror_type femv_colors,
335 typename Kokkos::View<lno_t*, device_type >::host_mirror_type boundary_verts_view,
336 typename Kokkos::View<lno_t*,device_type>::host_mirror_type verts_to_recolor,
337 typename Kokkos::View<int*,device_type>::host_mirror_type verts_to_recolor_size,
338 typename Kokkos::View<lno_t*,device_type>::host_mirror_type verts_to_send,
339 typename Kokkos::View<size_t*,device_type>::host_mirror_type verts_to_send_size,
340 typename Kokkos::View<size_t*, device_type>::host_mirror_type recoloringSize,
341 typename Kokkos::View<int*, device_type>::host_mirror_type rand,
342 typename Kokkos::View<gno_t*,device_type>::host_mirror_type gid,
343 typename Kokkos::View<gno_t*,device_type>::host_mirror_type ghost_degrees,
344 bool recolor_degrees) {
345 this->detectD2Conflicts<host_exec, host_mem>(n_local,
351 verts_to_recolor_size,
363 Kokkos::View<offset_t*, device_type> dist_offsets_dev,
364 Kokkos::View<lno_t*, device_type> dist_adjs_dev,
365 typename Kokkos::View<offset_t*, device_type>::host_mirror_type dist_offsets_host,
366 typename Kokkos::View<lno_t*, device_type>::host_mirror_type dist_adjs_host,
367 Kokkos::View<lno_t*, device_type>& boundary_verts,
370 Kokkos::View<
size_t*,
372 Kokkos::MemoryTraits<Kokkos::Atomic>> verts_to_send_size_atomic){
375 gno_t boundary_size_temp = 0;
376 for(
size_t i = 0; i < n_local; i++){
377 for(
offset_t j = dist_offsets_host(i); j < dist_offsets_host(i+1); j++){
378 if((
size_t)dist_adjs_host(j) >= n_local){
379 boundary_size_temp++;
383 for(
offset_t k = dist_offsets_host(dist_adjs_host(j)); k < dist_offsets_host(dist_adjs_host(j)+1); k++){
384 if((
size_t)dist_adjs_host(k) >= n_local){
385 boundary_size_temp++;
395 boundary_verts = Kokkos::View<lno_t*, device_type>(
"boundary verts",boundary_size_temp);
396 typename Kokkos::View<lno_t*, device_type>::host_mirror_type boundary_verts_host = Kokkos::create_mirror_view(boundary_verts);
399 boundary_size_temp = 0;
402 for(
size_t i = 0; i < n_local; i++){
403 for(
offset_t j = dist_offsets_host(i); j < dist_offsets_host(i+1); j++){
404 if((
size_t)dist_adjs_host(j) >= n_local){
405 boundary_verts_host(boundary_size_temp++) = i;
409 for(
offset_t k = dist_offsets_host(dist_adjs_host(j)); k < dist_offsets_host(dist_adjs_host(j)+1); k++){
410 if((
size_t)dist_adjs_host(k) >= n_local){
411 boundary_verts_host(boundary_size_temp++) = i;
420 Kokkos::deep_copy(boundary_verts, boundary_verts_host);
423 Kokkos::parallel_for(
"init verts to send",
424 Kokkos::RangePolicy<execution_space, int>(0,n_local),
425 KOKKOS_LAMBDA(
const int& i){
426 for(
offset_t j = dist_offsets_dev(i); j < dist_offsets_dev(i+1); j++){
427 if((
size_t)dist_adjs_dev(j) >= n_local){
428 verts_to_send_view(verts_to_send_size_atomic(0)++) = i;
432 for(
offset_t k = dist_offsets_dev(dist_adjs_dev(j)); k < dist_offsets_dev(dist_adjs_dev(j)+1); k++){
433 if((
size_t)dist_adjs_dev(k) >= n_local){
434 verts_to_send_view(verts_to_send_size_atomic(0)++) = i;