예제 #1
0
        private void TestBandwidth(Context context, Device[] devices, int start, int end, int increment, TestMode testMode, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
        {
            switch (testMode)
            {
            case TestMode.Quick:
                TestBandwidthQuick(context, devices, DefaultSize, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
                break;

            case TestMode.Range:
                TestBandwidthRange(context, devices, start, end, increment, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
                break;

            case TestMode.Shmoo:
                TestBandwidthShmoo(context, devices, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
                break;

            default:
                break;
            }
        }
예제 #2
0
 private void TestBandwidthShmoo(Context context, Device[] devices, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
 {
     throw new NotImplementedException();
 }
예제 #3
0
        private void TestBandwidthRange(Context context, Device[] devices, int start, int end, int increment, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
        {
            //count the number of copies we're going to run
            int count = 1 + ((end - start) / increment);
            int[] memSizes = new int[count];
            double[] bandwidths = new double[count];

            // Before calculating the cumulative bandwidth, initialize bandwidths array to NULL
            for (int i = 0; i < count; i++)
                bandwidths[i] = 0.0;

            // Use the device asked by the user
            for (int currentDevice = startDevice; currentDevice <= endDevice; currentDevice++)
            {
                // Allocate command queue for the device (dealloc first if already allocated)
                using (CommandQueue queue = CreateQueue(context, devices[currentDevice]))
                {
                    //run each of the copies
                    for (int i = 0; i < count; i++)
                    {
                        memSizes[i] = start + i * increment;
                        switch (memoryCopyKind)
                        {
                        case MemoryCopyKind.DeviceToHost:
                            bandwidths[i] += TestDeviceToHostTransfer(context, queue, memSizes[i], accessMode, memoryMode);
                            break;

                        case MemoryCopyKind.HostToDevice:
                            bandwidths[i] += TestHostToDeviceTransfer(context, queue, memSizes[i], accessMode, memoryMode);
                            break;

                        case MemoryCopyKind.DeviceToDevice:
                            bandwidths[i] += TestDeviceToDeviceTransfer(context, queue, memSizes[i]);
                            break;
                        }
                    }
                }
            } // Complete the bandwidth computation on all the devices

            //print results
            if (printMode == PrintMode.Csv)
            {
                PrintResultsCsv(memSizes, bandwidths, count, memoryCopyKind, accessMode, memoryMode, (1 + endDevice - startDevice));
            }
            else
            {
                PrintResultsReadable(memSizes, bandwidths, count, memoryCopyKind, accessMode, memoryMode, (1 + endDevice - startDevice));
            }
        }
예제 #4
0
 private void TestBandwidthQuick(Context context, Device[] devices, int size, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
 {
     TestBandwidthRange(context, devices, size, size, DefaultIncrement, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
 }
예제 #5
0
        private void PrintResultsReadable(int[] memSizes, double[] bandwidths, int count, MemoryCopyKind memoryCopyKind, AccessMode accessMode, MemoryMode memoryMode, int p)
        {
            if (memoryCopyKind == MemoryCopyKind.DeviceToDevice)
            {
                Console.WriteLine("Device to device bandwidth: {0} devices(s)", p);
            }
            else
            {
                if (memoryCopyKind == MemoryCopyKind.DeviceToHost)
                {
                    Console.Write("Device to host bandwidth: {0} devices(s), ", p);
                }
                else if (memoryCopyKind == MemoryCopyKind.HostToDevice)
                {
                    Console.Write("Host to device bandwidth: {0} devices(s), ", p);
                }

                if (memoryMode == MemoryMode.Pageable)
                {
                    Console.Write("Paged memory");
                }
                else if (memoryMode == MemoryMode.Pinned)
                {
                    Console.Write("Pinned memory");
                }

                if (accessMode == AccessMode.Direct)
                {
                    Console.WriteLine(", direct access");
                }
                else if (accessMode == AccessMode.Mapped)
                {
                    Console.WriteLine(", mapped access");
                }
            }

            Console.WriteLine("   Transfer size (bytes)\tBandwidth (MB/s)");
            for (int i = 0; i < count; i++)
            {
                Console.WriteLine("   {0}\t\t\t{1}{2}", memSizes[i], memSizes[i] < 10000 ? "\t" : "", bandwidths[i]);
            }

            Console.WriteLine();
        }
예제 #6
0
 private void PrintResultsCsv(int[] memSizes, double[] bandwidths, int count, MemoryCopyKind memoryCopyKind, AccessMode accessMode, MemoryMode memoryMode, int p)
 {
     throw new NotImplementedException();
 }
예제 #7
0
        private void TestBandwidth(Context context, Device[] devices, int start, int end, int increment, TestMode testMode, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
        {
            switch (testMode)
            {
            case TestMode.Quick:
                TestBandwidthQuick(context, devices, DefaultSize, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
                break;

            case TestMode.Range:
                TestBandwidthRange(context, devices, start, end, increment, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
                break;

            case TestMode.Shmoo:
                TestBandwidthShmoo(context, devices, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
                break;

            default:
                break;
            }
        }
예제 #8
0
 private void TestBandwidthShmoo(Context context, Device[] devices, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
 {
     throw new NotImplementedException();
 }
예제 #9
0
        private void TestBandwidthRange(Context context, Device[] devices, int start, int end, int increment, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
        {
            // count the number of copies we're going to run
            int count = 1 + ((end - start) / increment);

            int[]    memSizes   = new int[count];
            double[] bandwidths = new double[count];

            // Before calculating the cumulative bandwidth, initialize bandwidths array to NULL
            for (int i = 0; i < count; i++)
            {
                bandwidths[i] = 0.0;
            }

            // Use the device asked by the user
            for (int currentDevice = startDevice; currentDevice <= endDevice; currentDevice++)
            {
                // Allocate command queue for the device (dealloc first if already allocated)
                using (CommandQueue queue = CreateQueue(context, devices[currentDevice]))
                {
                    // run each of the copies
                    for (int i = 0; i < count; i++)
                    {
                        memSizes[i] = start + (i * increment);
                        switch (memoryCopyKind)
                        {
                        case MemoryCopyKind.DeviceToHost:
                            bandwidths[i] += TestDeviceToHostTransfer(context, queue, memSizes[i], accessMode, memoryMode);
                            break;

                        case MemoryCopyKind.HostToDevice:
                            bandwidths[i] += TestHostToDeviceTransfer(context, queue, memSizes[i], accessMode, memoryMode);
                            break;

                        case MemoryCopyKind.DeviceToDevice:
                            bandwidths[i] += TestDeviceToDeviceTransfer(context, queue, memSizes[i]);
                            break;
                        }
                    }
                }
            } // Complete the bandwidth computation on all the devices

            // print results
            if (printMode == PrintMode.Csv)
            {
                PrintResultsCsv(memSizes, bandwidths, count, memoryCopyKind, accessMode, memoryMode, 1 + endDevice - startDevice);
            }
            else
            {
                PrintResultsReadable(memSizes, bandwidths, count, memoryCopyKind, accessMode, memoryMode, 1 + endDevice - startDevice);
            }
        }
예제 #10
0
 private void TestBandwidthQuick(Context context, Device[] devices, int size, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
 {
     TestBandwidthRange(context, devices, size, size, DefaultIncrement, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
 }