1 31 package org.objectweb.proactive.core.group.spmd; 32 33 import org.objectweb.proactive.ActiveObjectCreationException; 34 import org.objectweb.proactive.ProActive; 35 import org.objectweb.proactive.core.body.AbstractBody; 36 import org.objectweb.proactive.core.group.Group; 37 import org.objectweb.proactive.core.group.ProActiveGroup; 38 import org.objectweb.proactive.core.group.ProxyForGroup; 39 import org.objectweb.proactive.core.mop.ClassNotReifiableException; 40 import org.objectweb.proactive.core.node.Node; 41 import org.objectweb.proactive.core.node.NodeException; 42 43 44 64 public class ProSPMD { 65 66 78 public static Object newSPMDGroup(String className, Object [][] params, 79 Node[] nodeList) 80 throws ClassNotFoundException , ClassNotReifiableException, 81 ActiveObjectCreationException, NodeException { 82 Object result = ProActiveGroup.newGroup(className); 87 Group g = ProActiveGroup.getGroup(result); 88 89 for (int i = 0; i < params.length; i++) 90 g.add(ProActive.newActive(className, params[i], 91 nodeList[i % nodeList.length])); 92 93 ((ProxyForGroup) g).setSPMDGroup(result); 94 95 return result; 96 } 97 98 public static Object newSPMDGroup(String className, Object [][] params, 99 String [] nodeList) 100 throws ClassNotFoundException , ClassNotReifiableException, 101 ActiveObjectCreationException, NodeException { 102 Object result = ProActiveGroup.newGroup(className); 107 Group g = ProActiveGroup.getGroup(result); 108 109 for (int i = 0; i < params.length; i++) 110 g.add(ProActive.newActive(className, params[i], 111 nodeList[i % nodeList.length])); 112 113 ((ProxyForGroup) g).setSPMDGroup(result); 114 115 return result; 116 } 117 118 122 public static void setSPMDGroupOnThis(Object o) { 123 AbstractBody body = (AbstractBody) ProActive.getBodyOnThis(); 124 body.setSPMDGroup(o); 125 } 126 127 131 public static Object getSPMDGroup() { 132 AbstractBody body = (AbstractBody) ProActive.getBodyOnThis(); 133 return body.getSPMDGroup(); 134 } 135 136 140 public int getMySPMDGroupSize() { 141 return ProActiveGroup.getGroup(ProSPMD.getSPMDGroup()).size(); 142 } 143 144 148 public int getMyRank() { 149 return ProActiveGroup.getGroup(ProSPMD.getSPMDGroup()).indexOf(ProActive.getStubOnThis()); 150 } 151 152 } 153 | Popular Tags |