public void Reduce <T> (int facet, T[] inValues, ReductionOperation <T> op, int root, ref T[] outValues) { int conversation_tag = takeNextConversationTag(); this.RootCommunicator.Send <Tuple <int, int> >(new Tuple <int, int>(AliencommunicatorOperation.REDUCE_ARRAY, conversation_tag), 0, TAG_SEND_OPERATION + 0); throw new NotImplementedException(); }
public void ReduceScatter <T> (int facet, T[] inValues, ReductionOperation <T> op, int[] counts, ref T[] outValues) { int conversation_tag = takeNextConversationTag(); /* lock (lock_mpi) */ this.RootCommunicator.Send <Tuple <int, int> >(new Tuple <int, int>(AliencommunicatorOperation.REDUCE_SCATTER, conversation_tag), 0, TAG_SEND_OPERATION + 0); throw new NotImplementedException(); }
internal T Reduce_impl <T>(int facet, bool isRoot, int size, T value, ReductionOperation <T> op, int root) { int conversation_tag = takeNextConversationTag(); this.RootCommunicator.Send <Tuple <int, int> >(new Tuple <int, int>(AliencommunicatorOperation.REDUCE, conversation_tag), 0, TAG_SEND_OPERATION + 0); throw new NotImplementedException(); }
// All Reduce public T Allreduce <T> (int facet, T value, ReductionOperation <T> op) { int conversation_tag = takeNextConversationTag(); this.RootCommunicator.Send <Tuple <int, int> >(new Tuple <int, int>(AliencommunicatorOperation.ALL_REDUCE, conversation_tag), 0, TAG_SEND_OPERATION + 0); throw new NotImplementedException(); }
/// <summary> /// Create a user-defined MPI operation based on the given reduction operation. /// </summary> /// <param name="op">The reduction operation.</param> public Operation(ReductionOperation <T> op) { // Try to find the predefined MPI operation mpiOp = GetPredefinedOperation(op); if (mpiOp == Unsafe.MPI_OP_NULL) { // Since we could not find a predefined operation, wrap up the user's operation // in a delegate that matches the signature of MPI_User_function unsafe { // Create the MPI_Op from the wrapper delegate if (UseGeneratedUserOps) { wrapperDelegate = MakeMPIDelegate(op); } else { WrapReductionOperation wrapper = new WrapReductionOperation(op); wrapperDelegate = new MPIDelegate(wrapper.Apply); } int errorCode = Unsafe.MPI_Op_create(Marshal.GetFunctionPointerForDelegate(wrapperDelegate), 0, out mpiOp); if (errorCode != Unsafe.MPI_SUCCESS) { throw Environment.TranslateErrorIntoException(errorCode); } } } }
T[] Aliencommunicator.Reduce <T> (int facet, T[] values, ReductionOperation <T> op, int root) { this.RootCommunicator.Send <AliencommunicatorOperation>(AliencommunicatorOperation.REDUCE, 0, TAG_SEND_OPERATION + 1); return(alien_communicator.Reduce <T> (facet, values, op, root)); }
// Reduce Array public T[] Reduce <T> (int facet, T[] values, ReductionOperation <T> op, int root) { T[] result = null; Reduce(facet, values, op, root, ref result); return(result); }
// Reduce public T Reduce <T> (int facet, T value, ReductionOperation <T> op, int root) { return(Reduce_impl <T>(facet, (root == Root), RemoteSize, value, op, root)); }
// Reduce-Scatter public T[] ReduceScatter <T> (int facet, T[] values, ReductionOperation <T> op, int[] counts) { T[] result = null; ReduceScatter(facet, values, op, counts, ref result); return(result); }
// All Reduce Array public T[] Allreduce <T> (int facet, T[] values, ReductionOperation <T> op) { T[] result = null; Allreduce(facet, values, op, ref result); return(result); }
public ReductionOperationView(ReductionOperation content) : this() { Content = content; }
public UserOperations(ReductionOperation <T> op) : base(op) { }
void Aliencommunicator.ReduceScatter <T> (int facet, T[] inValues, ReductionOperation <T> op, int[] counts, ref T[] outValues) { this.RootCommunicator.Send <AliencommunicatorOperation>(AliencommunicatorOperation.REDUCE_SCATTER, 0, TAG_SEND_OPERATION + 1); alien_communicator.ReduceScatter <T> (facet, inValues, op, counts, ref outValues); }
// Reduce-Scatter T[] Aliencommunicator.ReduceScatter <T> (int facet, T[] values, ReductionOperation <T> op, int[] counts) { this.RootCommunicator.Send <AliencommunicatorOperation>(AliencommunicatorOperation.REDUCE_SCATTER, 0, TAG_SEND_OPERATION + 0); return(alien_communicator.ReduceScatter <T> (facet, values, op, counts)); }
// All Reduce T Aliencommunicator.Allreduce <T> (int facet, T value, ReductionOperation <T> op) { this.RootCommunicator.Send <AliencommunicatorOperation>(AliencommunicatorOperation.ALL_REDUCE, 0, TAG_SEND_OPERATION + 0); return(alien_communicator.Allreduce <T> (facet, value, op)); }
/// <summary> /// Construct a new reduction operation wrapper. /// </summary> public WrapReductionOperation(ReductionOperation <T> op) { this.op = op; }
/// <summary> /// Creates a new MPI delegate from a reduction operation. /// </summary> private MPIDelegate MakeMPIDelegate(ReductionOperation <T> op) { if (mpiDelegateMethod == null) { unsafe { // Build the new mpiDelegateMethod mpiDelegateMethod = new DynamicMethod("reduce:" + typeof(T).ToString(), typeof(void), // op invec inoutvec count datatype new Type[] { typeof(ReductionOperation <T>), typeof(void *), typeof(void *), typeof(int *), typeof(MPI_Datatype *) }, typeof(ReductionOperation <T>)); } ILGenerator generator = mpiDelegateMethod.GetILGenerator(); // Local variables: /*loopCounter*/ generator.DeclareLocal(typeof(int)); /*count*/ generator.DeclareLocal(typeof(int)); // Labels we'll be using to jump around Label loopStart = generator.DefineLabel(); Label loopDone = generator.DefineLabel(); // Initialize loopCounter with zero generator.Emit(OpCodes.Ldc_I4_0); generator.Emit(OpCodes.Stloc_0); // Load the count into "count" generator.Emit(OpCodes.Ldarg_3); generator.Emit(OpCodes.Ldind_I4); // TODO: Can we assume "int" is always 32 bits? It is for Windows 32- and 64-bit generator.Emit(OpCodes.Stloc_1); // We're at the beginning of the loop generator.MarkLabel(loopStart); // Test to see whether we're done. If so, jump to loopDone generator.Emit(OpCodes.Ldloc_0); generator.Emit(OpCodes.Ldloc_1); generator.Emit(OpCodes.Clt); generator.Emit(OpCodes.Brfalse, loopDone); // Load the address of inoutvec[loopCounter] onto the stack, to be used after we invoke the delegate generator.Emit(OpCodes.Ldarg_2); // Load the delegate onto the stack generator.Emit(OpCodes.Ldarg_0); // Load the first argument (invec[loopCounter]) to the user delegate generator.Emit(OpCodes.Ldarg_1); generator.Emit(OpCodes.Ldobj, typeof(T)); // Load the second argument (inoutvec[loopCounter]) to the user delegate generator.Emit(OpCodes.Ldarg_2); generator.Emit(OpCodes.Ldobj, typeof(T)); // Call the delegate generator.EmitCall(OpCodes.Callvirt, typeof(ReductionOperation <T>).GetMethod("Invoke", new Type[] { typeof(T), typeof(T) }), null); // Store the intermediate back into inoutvec generator.Emit(OpCodes.Stobj, typeof(T)); // Increment the loop count generator.Emit(OpCodes.Ldloc_0); generator.Emit(OpCodes.Ldc_I4_1); generator.Emit(OpCodes.Add); generator.Emit(OpCodes.Stloc_0); // Increment invec by the size of T generator.Emit(OpCodes.Ldarg_1); generator.Emit(OpCodes.Sizeof, typeof(T)); generator.Emit(OpCodes.Add); generator.Emit(OpCodes.Starg, 1); // Increment inoutvec by the size of T generator.Emit(OpCodes.Ldarg_2); generator.Emit(OpCodes.Sizeof, typeof(T)); generator.Emit(OpCodes.Add); generator.Emit(OpCodes.Starg, 2); // Jump to the beginning of the loop generator.Emit(OpCodes.Br, loopStart); // End of our function generator.MarkLabel(loopDone); generator.Emit(OpCodes.Ret); } // Return a delegate to call the mpiDelegateMethod return((MPIDelegate)mpiDelegateMethod.CreateDelegate(typeof(MPIDelegate), op)); }
/// <summary> /// Determine the predefined <c>MPI_Op</c> that is associated with /// this reduction operation. If no such <c>MPI_Op</c> exists, /// returns <see cref="Unsafe.MPI_OP_NULL"/>. /// </summary> public static MPI_Op GetPredefinedOperation(ReductionOperation <T> op) { // Predefined reduction operations with no representation in C# // MPI_LXOR: There is no equivalent operator in C# or C++ // MPI_MAXLOC: We don't permit the data type used in reduction to differ // from the type used in reduction. // MPI_MINLOC: We don't permit the data type used in reduction to differ // from the type used in reduction. // Min/max if (Kind == DatatypeKind.CInteger || Kind == DatatypeKind.FortranInteger || Kind == DatatypeKind.FloatingPoint) { if (op == min) { return(Unsafe.MPI_MIN); } if (op == max) { return(Unsafe.MPI_MAX); } } // Product/sum if (Kind == DatatypeKind.CInteger || Kind == DatatypeKind.FortranInteger || Kind == DatatypeKind.FloatingPoint || Kind == DatatypeKind.Complex) { if (op == add) { return(Unsafe.MPI_SUM); } if (op == multiply) { return(Unsafe.MPI_PROD); } } // Logical and/or/xor if (Kind == DatatypeKind.CInteger || Kind == DatatypeKind.Logical) { if (op == logicalAnd) { return(Unsafe.MPI_LAND); } if (op == logicalOr) { return(Unsafe.MPI_LOR); } } // Bitwise and/or/xor if (Kind == DatatypeKind.CInteger || Kind == DatatypeKind.FortranInteger || Kind == DatatypeKind.Byte) { if (op == bitwiseAnd) { return(Unsafe.MPI_BAND); } if (op == bitwiseOr) { return(Unsafe.MPI_BOR); } if (op == exclusiveOr) { return(Unsafe.MPI_BXOR); } } return(Unsafe.MPI_OP_NULL); }
void Aliencommunicator.Reduce <T> (int facet, T[] inValues, ReductionOperation <T> op, int root, ref T[] outValues) { this.RootCommunicator.Send <AliencommunicatorOperation>(AliencommunicatorOperation.REDUCE, 0, TAG_SEND_OPERATION + 2); alien_communicator.Reduce <T> (facet, inValues, op, root, ref outValues); }