[MOAB-dev] commit/MOAB: danwu: In ParallelComm::gather_data(), current code that copies tag data to each sequence of gents is incorrect (bytes per tag should be taken into account).

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Nov 5 11:14:56 CST 2013


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/b02855ba7891/
Changeset:   b02855ba7891
Branch:      master
User:        danwu
Date:        2013-11-05 18:14:39
Summary:     In ParallelComm::gather_data(), current code that copies tag data to each sequence of gents is incorrect (bytes per tag should be taken into account).

Affected #:  1 file

diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index ab29867..7c3f5c7 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -8738,7 +8738,7 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
     int sz_buffer = sizeof(int) + gather_ents.size()*(sizeof(int) + bytes_per_tag);
     void* senddata = malloc(sz_buffer);
     ((int*)senddata)[0] = (int) gather_ents.size();    
-    int * ptr_int = (int*)senddata + 1;
+    int* ptr_int = (int*)senddata + 1;
     rval = mbImpl->tag_get_data(id_tag, gather_ents, (void*)ptr_int);
     ptr_int = (int*)(senddata) + 1 + gather_ents.size();
     rval = mbImpl->tag_get_data(tag_handle, gather_ents, (void*)ptr_int);
@@ -8792,7 +8792,7 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
         }
       }
 
-      // If gents has multiple sequences, set tag data (stored in the temp buffer) on each sequence separately
+      // If gents has multiple sequences, copy tag data (stored in the temp buffer) to each sequence separately
       if (multiple_sequences) {
         Range::iterator iter = gents.begin();
         size_t start_idx = 0;
@@ -8800,8 +8800,9 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
           int count;
           void* ptr;
           rval = mbImpl->tag_iterate(tag_handle, iter, gents.end(), count, ptr);
-          for (int i = 0; i < count; i++)
-            ((char*)ptr)[i] = ((char*)gvals)[start_idx + i];
+          assert(NULL != ptr);
+          assert(count > 0);
+          memcpy((char*)ptr, (char*)gvals + start_idx * bytes_per_tag, bytes_per_tag * count);
 
           iter += count;
           start_idx += count;

Repository URL: https://bitbucket.org/fathomteam/moab/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the moab-dev mailing list