KOKKOS_INLINE_FUNCTION void operator() ( const team_member & dev) const { Kokkos::View<int**,Kokkos::MemoryUnmanaged> l_histogram(dev.team_shmem(),TEAM_SIZE,TEAM_SIZE); Kokkos::View<int*,Kokkos::MemoryUnmanaged> l_data(dev.team_shmem(),chunk_size+1); const int i = dev.league_rank() * chunk_size; for(int j = dev.team_rank(); j<chunk_size+1; j+=dev.team_size()) l_data(j) = data(i+j); for(int k = dev.team_rank(); k < TEAM_SIZE; k+=dev.team_size()) for(int l = 0; l < TEAM_SIZE; l++) l_histogram(k,l) = 0; dev.team_barrier(); for(int j = 0; j<chunk_size; j++) { for(int k = dev.team_rank(); k < TEAM_SIZE; k+=dev.team_size()) for(int l = 0; l < TEAM_SIZE; l++) { if((l_data(j) == k) && (l_data(j+1)==l)) l_histogram(k,l)++; } } for(int k = dev.team_rank(); k < TEAM_SIZE; k+=dev.team_size()) for(int l = 0; l < TEAM_SIZE; l++) { Kokkos::atomic_fetch_add(&histogram(k,l),l_histogram(k,l)); } dev.team_barrier(); }
KOKKOS_INLINE_FUNCTION void operator()(const team_member & teamMember) const{ int ii = teamMember.league_rank() * teamMember.team_size() + teamMember.team_rank() + color_set_begin; if(ii >= color_set_end) return; #ifdef REORDER int crow = ii;//colors_ind(ii); #else int crow = colors_ind(ii); #endif int row_begin = A.graph.row_map(crow); int row_end = A.graph.row_map(crow+1); bool am_i_the_diagonal = false; double diagonal = 1; double sum = 0; Kokkos::parallel_reduce( Kokkos::ThreadVectorRange(teamMember, row_end - row_begin), [&] (int i, double & valueToUpdate) { int adjind = i + row_begin; int colIndex = A.graph.entries(adjind); double val = A.values(adjind); if(colIndex == crow){ diagonal = val; am_i_the_diagonal = true; } else{ valueToUpdate += val * xv(colIndex); } }, sum); if(am_i_the_diagonal){ xv(crow) = (rv(crow) - sum)/diagonal; } }
// This is a reduction operator which now takes as first argument the // TeamPolicy member_type. Every member of the team contributes to the // total sum. // It is helpful to think of this operator as a parallel region for a team // (i.e. every team member is active and will execute the code). KOKKOS_INLINE_FUNCTION void operator() ( const team_member & thread, int& sum) const { sum+=1; // The TeamPolicy<>::member_type provides functions to query the multi // dimensional index of a thread as well as the number of thread-teams and the size // of each team. printf("Hello World: %i %i // %i %i\n",thread.league_rank(),thread.team_rank(),thread.league_size(),thread.team_size()); }