static void Main()

in Benchmarks/Netcoll_cs/netcoll_cs.cs [71:155]


    static void Main(string[] args)
    {
        // By default, test with primitives types and the predefined MPI_SUM
        Test test = testPrimitiveAndPredefined;

        using (new MPI.Environment(ref args))
        {
            if (args.Length > 0 && args[0] == "/direct")
            {
                test = testDirect;
                System.Console.WriteLine("Using direct MPI interface.");
            }
            else if (args.Length > 0 && args[0] == "/user")
            {
                test = testPrimitiveAndMethod;
                Operation<double>.UseGeneratedUserOps = true;
                System.Console.WriteLine("Using primitive type (double) with user-defined sum and run-time code generation");
            }
            else if (args.Length > 0 && args[0] == "/marshaluser")
            {
                test = testPrimitiveAndMethod;
                Operation<double>.UseGeneratedUserOps = false;
                System.Console.WriteLine("Using primitive type (double) with user-defined sum and marshalling");
            }
            else if (args.Length > 0 && args[0] == "/valuetype")
            {
                test = testValueType;
                System.Console.WriteLine("Using value types with user-defined sum");
            }
            else if (args.Length > 0 && args[0] == "/reftype")
            {
                test = testReferenceType;
                System.Console.WriteLine("Using reference types with user-defined sum");
            }
            else
                System.Console.WriteLine("Using MPI.NET interface.");

            comm = MPI.Communicator.world;
            self = comm.Rank;
            System.Console.WriteLine(comm.Rank + ": " + MPI.Environment.ProcessorName);

            bwstats = new Stats[nSamp];

            testLatency();
            testSyncTime();
            comm.Broadcast(ref latency, 0);

            if (self == 0)
            {
                System.Console.WriteLine("Latency: {0:F9}", latency);
                System.Console.WriteLine("Sync Time: {0:F9}", synctime);
                System.Console.WriteLine("Now starting main loop");
            }

            int n, nq;
            int inc = 1, len;
            int start = 0, end = 1024 * 1024 * 1024;
            int bufflen = start;
            double tlast = latency;

            for (n = nq = 0, len = start; tlast < stopTime && len <= end; len += inc, nq++)
            {
                if (nq > 2 && (nq % 2 != 0)) inc *= 2;
                int ipert, pert;
                for (ipert = 0, pert = (inc > PERT + 1) ? -PERT : 0;
                     pert <= PERT;
                     ipert++, n++, pert += (inc > PERT + 1) ? PERT : PERT + 1)
                {
                    int nRepeat = bufflen == 0 ?
                                  latencyReps :
                                  (int)Math.Max((RUNTM / ((double)bufflen / (bufflen - inc + 1.0) * tlast)),
                                                TRIALS);
                    comm.Broadcast(ref nRepeat, 0);

                    bufflen = len + pert;
                    if (self == 0)
                        System.Console.Write("{0,3:D}: {1,9:D} doubles {2,7:D} times ---> ", n, bufflen, nRepeat);
                    GC.Collect();
                    test(bufflen, n, nRepeat, ref tlast);
                    if (self == 0)
                        System.Console.WriteLine("{0,9:F2} Mbps in {1:F9} sec", bwstats[n].bps, tlast);
                }
            }
        }
    }