From 6b537784e9c345dee7f7cfd108c6abc779a969ae Mon Sep 17 00:00:00 2001
From: Nicolas Bock <nicolasbock@gmail.com>
Date: Fri, 27 Sep 2013 10:50:45 -0600
Subject: [PATCH 2/4] Fixed bug in CkReductionMgr::reduceMessages().

The first contribution of a child node is a single message. In this case
CkReductionMgr::reduceMessages() simply returns the message without calling
the reducer. However, when using the CkReduction::set reducer this behavior is
incorrect, and instead the reducer should be called even for one single
message so that the message is wrapped into a setElement struct. In the
current implementation, the reduction becomes corrupted because the
CkReduction::set() method one tier up in the reduction sizes the remote
contribution incorrectly assuming a setElement struct and not a simple
message.
---
 src/ck-core/ckreduction.C | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ck-core/ckreduction.C b/src/ck-core/ckreduction.C
index 07853a2..ef3e906 100644
--- a/src/ck-core/ckreduction.C
+++ b/src/ck-core/ckreduction.C
@@ -850,7 +850,7 @@ CkReductionMsg *CkReductionMgr::reduceMessages(void)
   else
   {//Use the reducer to reduce the messages
 		//if there is only one msg to be reduced just return that message
-    if(nMsgs == 1){
+    if(nMsgs == 1 && msgArr[0]->reducer != CkReduction::set) {
 	ret = msgArr[0];	
     }else{
       if (msgArr[0]->reducer == CkReduction::random) {
-- 
1.8.1.5

