I am not sure about the place where flush should be used (if it is used at all here).
int Window_Shift :: get_window_shift()
{
int window_shift = INFINITE;
#pragma omp parallel for
for(unsigned int node_id = 0;node_id< no_of_valid_nodes ;node_id++)
{
//for all the nodes that can be extended
//finds the minimum possible window shift
if(can_node_determine_window_shift(node_id) == true)
{
int node_window_shift = get_window_shift_for_node(node_id);
#pragma omp flush(window_shift)
#pragma omp critical(get_window_shift_for_node)
{
window_shift = min(window_shift,node_window_shift);
#pragma omp flush(window_shift)
}
}
}
Please review the code, especially the flush()
commands. Should atomic be used instead of a critical section?