Skip to main content
deleted 20 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

The following is my code. 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 flushflush() commands. Should atomic be used instead of a critical section?

The following is my code. 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 critical section?

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?

edited tags
Link
200_success
  • 145.6k
  • 22
  • 191
  • 481
Post Reopened by MrSmith42, syb0rg, Jamal
added 5 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

The following is my code. 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, speciallyespecially the flush commands.Should Should atomic be used instead of critical section.?

The following is my code. 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, specially the flush commands.Should atomic be used instead of critical section.

The following is my code. 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 critical section?

edited tags
Link
priyanka
  • 215
  • 1
  • 5
Loading
added 50 characters in body
Source Link
priyanka
  • 215
  • 1
  • 5
Loading
added 53 characters in body
Source Link
priyanka
  • 215
  • 1
  • 5
Loading
Post Closed as "Not suitable for this site" by Jamal
Source Link
priyanka
  • 215
  • 1
  • 5
Loading