144 Kokkos::View<
offset_t*, Kokkos::Device<ExecutionSpace,MemorySpace>> dist_offsets,
145 Kokkos::View<
lno_t*, Kokkos::Device<ExecutionSpace, MemorySpace>> dist_adjs,
146 Kokkos::View<
int*, Kokkos::Device<ExecutionSpace, MemorySpace>> femv_colors,
147 Kokkos::View<
lno_t*, Kokkos::Device<ExecutionSpace, MemorySpace>> boundary_verts_view,
149 Kokkos::Device<ExecutionSpace, MemorySpace> > verts_to_recolor_view,
151 Kokkos::Device<ExecutionSpace, MemorySpace>,
152 Kokkos::MemoryTraits<Kokkos::Atomic> > verts_to_recolor_size_atomic,
154 Kokkos::Device<ExecutionSpace, MemorySpace> > verts_to_send_view,
155 Kokkos::View<
size_t*,
156 Kokkos::Device<ExecutionSpace, MemorySpace>,
157 Kokkos::MemoryTraits<Kokkos::Atomic> > verts_to_send_size_atomic,
158 Kokkos::View<
size_t*, Kokkos::Device<ExecutionSpace, MemorySpace>> recoloringSize,
159 Kokkos::View<
int*, Kokkos::Device<ExecutionSpace, MemorySpace>> rand,
160 Kokkos::View<
gno_t*, Kokkos::Device<ExecutionSpace, MemorySpace>> gid,
161 Kokkos::View<
gno_t*, Kokkos::Device<ExecutionSpace, MemorySpace>> ghost_degrees,
162 bool recolor_degrees){
163 Kokkos::RangePolicy<ExecutionSpace> policy(0, boundary_verts_view.extent(0));
164 size_t local_recoloring_size;
165 Kokkos::parallel_reduce(
"D2 conflict detection",policy, KOKKOS_LAMBDA(
const uint64_t& i,
size_t& recoloring_size){
167 const size_t curr_lid = boundary_verts_view(i);
168 const int curr_color = femv_colors(curr_lid);
169 const size_t vid_d1_adj_begin = dist_offsets(curr_lid);
170 const size_t vid_d1_adj_end = dist_offsets(curr_lid+1);
171 const size_t curr_degree = vid_d1_adj_end - vid_d1_adj_begin;
172 for(
size_t vid_d1_adj = vid_d1_adj_begin; vid_d1_adj < vid_d1_adj_end; vid_d1_adj++){
174 size_t vid_d1 = dist_adjs(vid_d1_adj);
175 size_t vid_d1_degree = 0;
177 if(vid_d1 < n_local){
178 vid_d1_degree = dist_offsets(vid_d1+1) - dist_offsets(vid_d1);
180 vid_d1_degree = ghost_degrees(vid_d1-n_local);
182 if( vid_d1 != curr_lid && femv_colors(vid_d1) == curr_color){
183 if(curr_degree < vid_d1_degree && recolor_degrees){
184 femv_colors(curr_lid) = 0;
187 }
else if (vid_d1_degree < curr_degree && recolor_degrees){
188 femv_colors(vid_d1) = 0;
190 }
else if(rand(curr_lid) < rand(vid_d1)){
191 femv_colors(curr_lid) = 0;
194 }
else if(rand(vid_d1) < rand(curr_lid)){
195 femv_colors(vid_d1) = 0;
198 if(gid(curr_lid) >= gid(vid_d1)){
199 femv_colors(curr_lid) = 0;
203 femv_colors(vid_d1) = 0;
208 size_t d2_adj_begin = 0;
209 size_t d2_adj_end = 0;
210 d2_adj_begin = dist_offsets(vid_d1);
211 d2_adj_end = dist_offsets(vid_d1+1);
217 for(
size_t vid_d2_adj = d2_adj_begin; vid_d2_adj < d2_adj_end; vid_d2_adj++){
219 const size_t vid_d2 = dist_adjs(vid_d2_adj);
220 size_t vid_d2_degree = 0;
222 if(vid_d2 < n_local){
223 vid_d2_degree = dist_offsets(vid_d2+1) - dist_offsets(vid_d2);
225 vid_d2_degree = ghost_degrees(vid_d2-n_local);
227 if(curr_lid != vid_d2 && femv_colors(vid_d2) == curr_color){
228 if(curr_degree < vid_d2_degree && recolor_degrees){
230 femv_colors(curr_lid) = 0;
233 }
else if(vid_d2_degree < curr_degree && recolor_degrees){
234 femv_colors(vid_d2) = 0;
236 }
else if(rand(curr_lid) < rand(vid_d2)){
238 femv_colors(curr_lid) = 0;
241 }
else if(rand(vid_d2) < rand(curr_lid)){
242 femv_colors(vid_d2) = 0;
245 if(gid(curr_lid) >= gid(vid_d2)){
247 femv_colors(curr_lid) = 0;
251 femv_colors(vid_d2) = 0;
259 },local_recoloring_size);
260 Kokkos::deep_copy(recoloringSize,local_recoloring_size);
264 Kokkos::parallel_for(
"rebuild verts_to_send and verts_to_recolor",
265 Kokkos::RangePolicy<ExecutionSpace>(0,femv_colors.size()),
266 KOKKOS_LAMBDA(
const uint64_t& i){
267 if(femv_colors(i) == 0){
270 verts_to_send_view(verts_to_send_size_atomic(0)++) = i;
273 verts_to_recolor_view(verts_to_recolor_size_atomic(0)++) = i;
282 Kokkos::View<offset_t*, device_type > dist_offsets_dev,
283 Kokkos::View<lno_t*, device_type > dist_adjs_dev,
284 Kokkos::View<int*,device_type > femv_colors,
285 Kokkos::View<lno_t*, device_type > boundary_verts_view,
290 Kokkos::MemoryTraits<Kokkos::Atomic>> verts_to_recolor_size_atomic,
293 Kokkos::View<
size_t*,
295 Kokkos::MemoryTraits<Kokkos::Atomic>> verts_to_send_size_atomic,
296 Kokkos::View<size_t*, device_type> recoloringSize,
303 bool recolor_degrees){
305 this->detectD2Conflicts<execution_space, memory_space>(n_local,
310 verts_to_recolor_view,
311 verts_to_recolor_size_atomic,
313 verts_to_send_size_atomic,
322 typename Kokkos::View<offset_t*, device_type >::HostMirror dist_offsets_host,
323 typename Kokkos::View<lno_t*, device_type >::HostMirror dist_adjs_host,
324 typename Kokkos::View<int*,device_type >::HostMirror femv_colors,
325 typename Kokkos::View<lno_t*, device_type >::HostMirror boundary_verts_view,
326 typename Kokkos::View<lno_t*,device_type>::HostMirror verts_to_recolor,
327 typename Kokkos::View<int*,device_type>::HostMirror verts_to_recolor_size,
328 typename Kokkos::View<lno_t*,device_type>::HostMirror verts_to_send,
329 typename Kokkos::View<size_t*,device_type>::HostMirror verts_to_send_size,
330 typename Kokkos::View<size_t*, device_type>::HostMirror recoloringSize,
331 typename Kokkos::View<int*, device_type>::HostMirror rand,
332 typename Kokkos::View<gno_t*,device_type>::HostMirror gid,
333 typename Kokkos::View<gno_t*,device_type>::HostMirror ghost_degrees,
334 bool recolor_degrees) {
335 this->detectD2Conflicts<host_exec, host_mem>(n_local,
341 verts_to_recolor_size,
353 Kokkos::View<offset_t*, device_type> dist_offsets_dev,
354 Kokkos::View<lno_t*, device_type> dist_adjs_dev,
355 typename Kokkos::View<offset_t*, device_type>::HostMirror dist_offsets_host,
356 typename Kokkos::View<lno_t*, device_type>::HostMirror dist_adjs_host,
357 Kokkos::View<lno_t*, device_type>& boundary_verts,
360 Kokkos::View<
size_t*,
362 Kokkos::MemoryTraits<Kokkos::Atomic>> verts_to_send_size_atomic){
365 gno_t boundary_size_temp = 0;
366 for(
size_t i = 0; i < n_local; i++){
367 for(
offset_t j = dist_offsets_host(i); j < dist_offsets_host(i+1); j++){
368 if((
size_t)dist_adjs_host(j) >= n_local){
369 boundary_size_temp++;
373 for(
offset_t k = dist_offsets_host(dist_adjs_host(j)); k < dist_offsets_host(dist_adjs_host(j)+1); k++){
374 if((
size_t)dist_adjs_host(k) >= n_local){
375 boundary_size_temp++;
385 boundary_verts = Kokkos::View<lno_t*, device_type>(
"boundary verts",boundary_size_temp);
386 typename Kokkos::View<lno_t*, device_type>::HostMirror boundary_verts_host = Kokkos::create_mirror_view(boundary_verts);
389 boundary_size_temp = 0;
392 for(
size_t i = 0; i < n_local; i++){
393 for(
offset_t j = dist_offsets_host(i); j < dist_offsets_host(i+1); j++){
394 if((
size_t)dist_adjs_host(j) >= n_local){
395 boundary_verts_host(boundary_size_temp++) = i;
399 for(
offset_t k = dist_offsets_host(dist_adjs_host(j)); k < dist_offsets_host(dist_adjs_host(j)+1); k++){
400 if((
size_t)dist_adjs_host(k) >= n_local){
401 boundary_verts_host(boundary_size_temp++) = i;
410 Kokkos::deep_copy(boundary_verts, boundary_verts_host);
413 Kokkos::parallel_for(n_local, KOKKOS_LAMBDA(
const int& i){
414 for(
offset_t j = dist_offsets_dev(i); j < dist_offsets_dev(i+1); j++){
415 if((
size_t)dist_adjs_dev(j) >= n_local){
416 verts_to_send_view(verts_to_send_size_atomic(0)++) = i;
420 for(
offset_t k = dist_offsets_dev(dist_adjs_dev(j)); k < dist_offsets_dev(dist_adjs_dev(j)+1); k++){
421 if((
size_t)dist_adjs_dev(k) >= n_local){
422 verts_to_send_view(verts_to_send_size_atomic(0)++) = i;