@@ -73,18 +73,12 @@ struct CandidatePairs
7373 // / if we have a space to insert new pairs
7474
7575 auto add_candidate_with_indices = [&](int id) {
76- // add the handles
77- m_pairs_handle (id).first = c0;
78- m_pairs_handle (id).second = c1;
79-
8076 // add the indices
81- id *= m_variable_dim * m_variable_dim * 2 ;
82-
8377 for (int i = 0 ; i < m_variable_dim; ++i) {
8478 for (int j = 0 ; j < m_variable_dim; ++j) {
8579
86- int r_id = m_context. linear_id (c0) * m_variable_dim + i;
87- int c_id = m_context. linear_id (c1) * m_variable_dim + j;
80+ int r_id = m_hess. get_row_id (c0) * m_variable_dim + i;
81+ int c_id = m_hess. get_row_id (c1) * m_variable_dim + j;
8882
8983 m_pairs_id (id, 0 ) = r_id;
9084 m_pairs_id (id, 1 ) = c_id;
@@ -107,13 +101,13 @@ struct CandidatePairs
107101
108102#ifdef __CUDA_ARCH__
109103 int id = ::atomicAdd (m_current_num_pairs.data (DEVICE), 1 );
110- if (id < m_pairs_handle.rows ()) {
111- if (m_hess.is_non_zero (c0, c1)) {
104+ if (id < m_pairs_handle.rows ()) {
105+ add_candidate (id);
106+ if (!m_hess.is_non_zero (c0, c1)) {
112107 add_candidate (id);
113- } else {
114- ::atomicAdd (m_current_num_index.data(DEVICE),
115- m_variable_dim * m_variable_dim * 2);
116- add_candidate_with_indices (id);
108+ int idd = ::atomicAdd (m_current_num_index.data (DEVICE),
109+ m_variable_dim * m_variable_dim * 2 );
110+ add_candidate_with_indices (idd);
117111 }
118112 return true ;
119113 } else {
@@ -123,12 +117,12 @@ struct CandidatePairs
123117#else
124118 if (m_current_num_pairs (0 ) < m_pairs_handle.rows ()) {
125119 int id = m_current_num_pairs (0 );
126- m_current_num_pairs (0 )++;
127- if (m_hess. is_non_zero (c0, c1)) {
128- add_candidate (id);
129- } else {
120+ m_current_num_pairs (0 )++;
121+ add_candidate (id);
122+ if (!m_hess. is_non_zero (c0, c1)) {
123+ int idd = m_current_num_index ( 0 );
130124 m_current_num_index (0 ) += m_variable_dim * m_variable_dim * 2 ;
131- add_candidate_with_indices (id );
125+ add_candidate_with_indices (idd );
132126 }
133127 return true ;
134128 } else {
0 commit comments