August Diamond
August Diamond

Reputation: 21

Atomic Operations do not provide updated value to other threads

    if(tid\<n) 
    {    
        gain = in_degree[neigh]*out_degree[tid] + out_degree[neighbour]*in_degree[tid]/total_weight   

        //here let say node 0 moves to 2 

        atomicExch(&node_community[0, node_community[2] // because node 0 is in node 2 now  
        atomicAdd(&in_degree[2],in_degree[0] // because node 0 is in node 2 now   

        atomicAdd(&out_degree[2],out_degree[0] // because node 0 is in node 2 now
    } 
}

this is the process, in this problem during calculation of gain all the thread should see the update value of 2 which values of 2+values 0 but threads see only previous value of 2.

how to solve that ? here is the output:

      node is: 0 
      node is: 1 
      node is: 2 
      node is: 3 
      node is: 4 
      node is: 5 
//HERE IS THS PROBLEM (UPDATED VALUES ARE NOT VISIBLE TO THE REST OF THREDS WHO EXECUTED BEFORE THE ATOMIC WRITE)

updated_node is: 0 // this should be 2 
updated_values are: 48,37. // this should be(48+15(values of 2))+(37+12(values of 0))  


                   comm.  in  out
    0 shifted to ->> 2 -  15 - 12
    1 shifted to ->> 1 -   8 -  10
    2 shifted to ->> 2 -   48 - 37

I have tried using , __syncthreads(), _threadfence() and shared memory foe reading writing values can any one tell what could be the issue ??

Upvotes: 1

Views: 37

Answers (0)

Related Questions