Skip to content

Add plan argument to 2D/3D FFT functions in cupyx.scipy.fftpack - #1942

Merged
asi1024 merged 20 commits into
cupy:masterfrom
leofang:fft_plan_arg
Feb 16, 2019
Merged

asi1024 merged 20 commits into
cupy:masterfrom
leofang:fft_plan_arg

Conversation

@leofang

@leofang leofang commented Jan 11, 2019 •

Copy link
Copy Markdown
Member

As discussed in #1669, it's desirable to pass explicitly a cuFFT plan to FFT functions. Since currently only PlanNd for C2C transforms is supported (see the PR #1746), following the same logic I changed the signatures for the following functions:

  • cupyx.scipy.fftpack.fft2
  • cupyx.scipy.fftpack.ifft2
  • cupyx.scipy.fftpack.fftn
  • cupyx.scipy.fftpack.ifftn

so that they accept a plan argument (defaulted to None). For users' convenience I also provide a handle cupyx.scipy.fftpack.get_fft_plan that returns a cuFFT plan for the target array with specified axes. These are the two deviations from the scipy.fftpack counterpart. But for users don't care about plans, the API is guaranteed compatible (I think).

Using the test script adapted from @grlee77's, in the reply below I show the performance gains for using an explicitly managed plan compared to an auto-generated plan as implemented in #1746. One can see that

  1. getting rid of the overhead for plan generation indeed gives better performance, especially for smaller arrays (for larger arrays most of the time is spent on number crunching, so generating a plan is relatively cheap),
  2. for 2D transforms, 3D arrays in C order perform better for axes=(1,2) while those in F order better for axes=(0,1),

both of which are expected observations.

Question: I am not sure how to write a proper test case. Since scipy.fftpack doesn't support plan, we shouldn't compare with the results from scipy.fftpack, should we? So what decorator should I put for the test cases? See also the comments I left in tests/cupyx_tests/scipy_tests/fftpack_tests/test_fftpack.py

TODO:

  • Get the tests done

@leofang

leofang commented Jan 11, 2019

Copy link
Copy Markdown
Member Author

Test script:

import cupy
from cupyx.scipy.fftpack import fftn, get_fft_plan
import numpy as np
from cupy.fft import config

config.enable_nd_planning = False
nruns = 20

print("Acceleration Factors (nd vs. 1d)):")
cupy.cuda.Device(3).use()
start = cupy.cuda.Event()
end = cupy.cuda.Event()

for order in ['C', 'F']:
    for sz in (512, 1024, 2048, 4096, 16000):
        for dim in (128, 192, 256, 320):
            # memory limitation
            if sz == 16000 and dim > 192:
                continue

            ndim = 3
            shape = [sz, ] * ndim
            for i in [1, 2]:
                shape[i] = dim
            shape = tuple(shape)

            if ndim == 3:
                # planned transforms are only possible if the first or last axis is included
                _axes = [(0,), (2,), (0, 1), (1, 2), (0, 1, 2)]

            for axes in _axes:
                a = cupy.random.randn(*shape).astype(np.complex64)
                if order == 'F':
                    a = cupy.asfortranarray(a)
                else:
                    a = cupy.ascontiguousarray(a)

                # case 1: no overwrite, no plan
                dur_1d = 0.
                for t in range(nruns):
                    start.record()
                    b = fftn(a, axes=axes)
                    end.record()
                    end.synchronize()
                    dur_1d += cupy.cuda.get_elapsed_time(start, end)
                dur_1d /= nruns

                # case 3: use overwrite, auto plan
                config.enable_nd_planning = True
                dur_3d = 0.
                for t in range(nruns):
                    start.record()
                    fftn(a, axes=axes, overwrite_x=True)
                    end.record()
                    end.synchronize()
                    dur_3d += cupy.cuda.get_elapsed_time(start, end)
                dur_3d /= nruns
                config.enable_nd_planning = False

                # case 4: use overwrite, explicit plan
                plan = get_fft_plan(a, axes=axes)
                dur_4d = 0.
                for t in range(nruns):
                    start.record()
                    fftn(a, axes=axes, overwrite_x=True, plan=plan)
                    end.record()
                    end.synchronize()
                    dur_4d += cupy.cuda.get_elapsed_time(start, end)
                dur_4d /= nruns

                print("\t(shape, axes, order, speedup (auto plan), speedup (explicit plan))"
                      " = ({:>17}, {:>9}, {}, {:>6.3f}, {:>6.3f})"
                      .format(str(shape), str(axes), order, dur_1d/dur_3d, dur_1d/dur_4d))

            print()

Output (run 1):

Acceleration Factors (nd vs. 1d)):
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),      (0,), C,  8.507, 51.208)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),      (2,), C,  1.132,  4.896)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),    (0, 1), C,  0.280,  0.327)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),    (1, 2), C,  1.480,  5.291)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128), (0, 1, 2), C,  1.706,  4.512)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),      (0,), C,  0.997,  8.614)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),      (2,), C,  0.873,  2.745)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),    (0, 1), C,  0.292,  0.303)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),    (1, 2), C,  1.386,  2.652)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192), (0, 1, 2), C,  2.948,  5.560)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),      (0,), C,  1.000,  8.887)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),      (2,), C,  0.919,  1.940)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),    (0, 1), C,  0.372,  0.381)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),    (1, 2), C,  1.585,  2.684)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256), (0, 1, 2), C,  5.389,  7.438)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),      (0,), C,  1.001,  8.842)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),      (2,), C,  0.938,  1.426)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),    (0, 1), C,  0.392,  0.397)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),    (1, 2), C,  1.940,  2.768)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320), (0, 1, 2), C,  5.942,  7.884)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),      (0,), C,  0.999,  6.948)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),      (2,), C,  0.969,  2.503)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),    (0, 1), C,  0.266,  0.280)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),    (1, 2), C,  1.280,  2.626)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128), (0, 1, 2), C,  2.507,  4.976)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),      (0,), C,  0.998,  5.459)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),      (2,), C,  1.095,  2.079)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),    (0, 1), C,  0.269,  0.273)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),    (1, 2), C,  1.766,  2.671)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192), (0, 1, 2), C,  4.568,  5.807)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),      (0,), C,  0.999,  5.161)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),      (2,), C,  0.998,  1.538)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),    (0, 1), C,  0.344,  0.347)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),    (1, 2), C,  2.174,  2.707)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256), (0, 1, 2), C,  5.858,  7.102)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),      (0,), C,  1.000,  5.260)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),      (2,), C,  0.989,  1.226)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),    (0, 1), C,  0.370,  0.372)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),    (1, 2), C,  2.399,  2.787)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320), (0, 1, 2), C,  6.651,  7.835)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),      (0,), C,  0.996,  1.521)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),      (2,), C,  0.971,  1.841)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),    (0, 1), C,  0.229,  0.231)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),    (1, 2), C,  1.539,  2.537)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128), (0, 1, 2), C,  3.279,  3.992)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),      (0,), C,  1.000,  1.383)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),      (2,), C,  0.973,  1.381)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),    (0, 1), C,  0.232,  0.233)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),    (1, 2), C,  2.193,  2.686)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192), (0, 1, 2), C,  4.047,  4.481)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),      (0,), C,  0.999,  1.231)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),      (2,), C,  0.989,  1.273)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),    (0, 1), C,  0.314,  0.314)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),    (1, 2), C,  2.316,  2.710)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256), (0, 1, 2), C,  5.181,  5.497)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),      (0,), C,  1.000,  1.141)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),      (2,), C,  0.925,  1.114)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),    (0, 1), C,  0.439,  0.440)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),    (1, 2), C,  2.588,  2.797)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320), (0, 1, 2), C,  5.975,  6.226)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),      (0,), C,  1.000,  2.040)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),      (2,), C,  0.978,  1.462)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),    (0, 1), C,  0.234,  0.237)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),    (1, 2), C,  2.054,  2.561)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128), (0, 1, 2), C,  3.792,  4.199)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),      (0,), C,  0.999,  1.784)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),      (2,), C,  0.987,  1.221)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),    (0, 1), C,  0.247,  0.248)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),    (1, 2), C,  2.128,  2.703)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192), (0, 1, 2), C,  4.245,  4.452)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),      (0,), C,  1.000,  1.475)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),      (2,), C,  0.997,  1.099)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),    (0, 1), C,  0.328,  0.329)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),    (1, 2), C,  2.506,  2.732)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256), (0, 1, 2), C,  5.499,  5.641)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),      (0,), C,  1.306,  1.845)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),      (2,), C,  0.989,  1.092)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),    (0, 1), C,  0.352,  0.352)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),    (1, 2), C,  2.689,  2.805)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320), (0, 1, 2), C,  6.089,  6.234)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),      (0,), C,  1.000,  0.988)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),      (2,), C,  0.995,  1.090)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),    (0, 1), C,  0.254,  0.255)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),    (1, 2), C,  2.418,  2.584)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128), (0, 1, 2), C,  4.335,  4.451)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),      (0,), C,  1.000,  0.891)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),      (2,), C,  0.987,  1.045)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),    (0, 1), C,  0.287,  0.287)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),    (1, 2), C,  2.601,  2.716)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192), (0, 1, 2), C,  4.699,  4.739)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),      (0,), F,  1.207,  6.525)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),      (2,), F,  0.981,  3.669)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),    (0, 1), F,  1.287,  3.943)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),    (1, 2), F,  0.301,  0.361)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128), (0, 1, 2), F,  1.984,  5.530)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),      (0,), F,  1.058,  2.999)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),      (2,), F,  0.984,  2.423)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),    (0, 1), F,  1.314,  3.113)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),    (1, 2), F,  0.188,  0.199)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192), (0, 1, 2), F,  1.533,  2.679)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),      (0,), F,  0.971,  2.322)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),      (2,), F,  0.904,  1.827)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),    (0, 1), F,  3.144,  5.515)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),    (1, 2), F,  0.259,  0.265)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256), (0, 1, 2), F,  3.559,  4.692)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),      (0,), F,  0.999,  2.340)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),      (2,), F,  0.993,  1.193)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),    (0, 1), F,  4.606,  6.259)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),    (1, 2), F,  0.248,  0.252)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320), (0, 1, 2), F,  3.924,  4.637)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),      (0,), F,  0.991,  2.526)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),      (2,), F,  1.013,  2.476)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),    (0, 1), F,  1.405,  2.748)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),    (1, 2), F,  0.231,  0.256)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128), (0, 1, 2), F,  1.603,  2.870)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),      (0,), F,  0.999,  2.306)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),      (2,), F,  0.981,  1.646)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),    (0, 1), F,  1.991,  3.293)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),    (1, 2), F,  0.146,  0.149)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192), (0, 1, 2), F,  2.171,  2.817)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),      (0,), F,  0.989,  2.311)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),      (2,), F,  0.987,  0.881)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),    (0, 1), F,  4.571,  5.953)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),    (1, 2), F,  0.249,  0.253)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256), (0, 1, 2), F,  3.519,  4.001)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),      (0,), F,  1.000,  2.355)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),      (2,), F,  0.989,  0.838)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),    (0, 1), F,  5.787,  6.760)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),    (1, 2), F,  0.225,  0.226)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320), (0, 1, 2), F,  4.209,  4.595)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),      (0,), F,  0.999,  2.307)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),      (2,), F,  0.886,  1.416)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),    (0, 1), F,  1.637,  2.613)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),    (1, 2), F,  0.171,  0.178)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128), (0, 1, 2), F,  1.728,  2.293)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),      (0,), F,  1.000,  2.345)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),      (2,), F,  0.903,  1.300)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),    (0, 1), F,  2.350,  2.967)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),    (1, 2), F,  0.177,  0.180)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192), (0, 1, 2), F,  2.426,  2.816)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),      (0,), F,  1.015,  2.457)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),      (2,), F,  0.968,  0.762)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),    (0, 1), F,  4.933,  5.868)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),    (1, 2), F,  0.251,  0.252)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256), (0, 1, 2), F,  3.699,  4.022)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),      (0,), F,  1.000,  2.365)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),      (2,), F,  0.996,  0.763)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),    (0, 1), F,  6.029,  6.530)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),    (1, 2), F,  0.250,  0.251)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320), (0, 1, 2), F,  4.512,  4.708)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),      (0,), F,  0.988,  2.246)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),      (2,), F,  1.015,  1.080)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),    (0, 1), F,  2.334,  2.956)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),    (1, 2), F,  0.200,  0.204)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128), (0, 1, 2), F,  2.217,  2.530)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),      (0,), F,  0.991,  2.292)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),      (2,), F,  1.005,  0.735)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),    (0, 1), F,  3.173,  3.532)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),    (1, 2), F,  0.197,  0.198)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192), (0, 1, 2), F,  2.458,  2.680)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),      (0,), F,  0.998,  2.325)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),      (2,), F,  0.999,  0.704)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),    (0, 1), F,  5.752,  6.101)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),    (1, 2), F,  0.252,  0.253)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256), (0, 1, 2), F,  4.034,  4.175)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),      (0,), F,  0.997,  2.324)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),      (2,), F,  0.995,  0.564)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),    (0, 1), F,  7.211,  7.503)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),    (1, 2), F,  0.269,  0.269)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320), (0, 1, 2), F,  4.153,  4.212)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),      (0,), F,  1.001,  1.555)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),      (2,), F,  0.936,  1.063)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),    (0, 1), F,  2.139,  2.241)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),    (1, 2), F,  0.188,  0.189)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128), (0, 1, 2), F,  2.232,  2.315)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),      (0,), F,  0.964,  1.201)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),      (2,), F,  0.982,  0.771)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),    (0, 1), F,  2.046,  2.639)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),    (1, 2), F,  0.179,  0.179)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192), (0, 1, 2), F,  2.362,  2.852)

Output (run 2):

Acceleration Factors (nd vs. 1d)):
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),      (0,), C,  9.725, 57.920)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),      (2,), C,  1.015,  4.460)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),    (0, 1), C,  0.304,  0.342)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),    (1, 2), C,  1.124,  4.233)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128), (0, 1, 2), C,  1.857,  4.284)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),      (0,), C,  1.001,  8.775)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),      (2,), C,  0.971,  2.303)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),    (0, 1), C,  0.293,  0.303)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),    (1, 2), C,  1.103,  2.711)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192), (0, 1, 2), C,  2.947,  5.516)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),      (0,), C,  1.001,  9.045)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),      (2,), C,  0.967,  1.768)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),    (0, 1), C,  0.373,  0.381)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),    (1, 2), C,  1.749,  2.684)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256), (0, 1, 2), C,  5.151,  7.436)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),      (0,), C,  1.000,  8.853)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),      (2,), C,  1.103,  1.694)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),    (0, 1), C,  0.396,  0.400)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),    (1, 2), C,  1.904,  2.766)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320), (0, 1, 2), C,  6.600,  7.903)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),      (0,), C,  0.998,  7.370)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),      (2,), C,  0.936,  2.992)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),    (0, 1), C,  0.269,  0.281)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),    (1, 2), C,  1.277,  2.739)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128), (0, 1, 2), C,  3.025,  5.068)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),      (0,), C,  0.997,  5.461)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),      (2,), C,  1.034,  1.910)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),    (0, 1), C,  0.269,  0.273)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),    (1, 2), C,  1.826,  2.673)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192), (0, 1, 2), C,  4.425,  5.770)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),      (0,), C,  1.000,  5.181)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),      (2,), C,  0.868,  1.363)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),    (0, 1), C,  0.343,  0.347)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),    (1, 2), C,  2.059,  2.703)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256), (0, 1, 2), C,  6.164,  7.106)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),      (0,), C,  1.000,  5.249)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),      (2,), C,  1.026,  1.290)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),    (0, 1), C,  0.373,  0.375)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),    (1, 2), C,  2.318,  2.788)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320), (0, 1, 2), C,  7.116,  7.797)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),      (0,), C,  0.999,  1.521)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),      (2,), C,  1.000,  1.787)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),    (0, 1), C,  0.227,  0.232)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),    (1, 2), C,  1.434,  2.499)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128), (0, 1, 2), C,  3.094,  4.002)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),      (0,), C,  1.000,  1.379)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),      (2,), C,  0.877,  1.363)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),    (0, 1), C,  0.232,  0.234)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),    (1, 2), C,  2.085,  2.688)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192), (0, 1, 2), C,  4.004,  4.483)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),      (0,), C,  1.000,  1.225)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),      (2,), C,  0.952,  1.188)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),    (0, 1), C,  0.315,  0.315)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),    (1, 2), C,  2.438,  2.740)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256), (0, 1, 2), C,  5.201,  5.501)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),      (0,), C,  1.000,  1.137)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),      (2,), C,  0.825,  1.112)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),    (0, 1), C,  0.447,  0.448)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),    (1, 2), C,  2.534,  2.794)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320), (0, 1, 2), C,  5.868,  6.201)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),      (0,), C,  1.000,  2.046)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),      (2,), C,  0.954,  1.390)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),    (0, 1), C,  0.234,  0.236)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),    (1, 2), C,  1.923,  2.565)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128), (0, 1, 2), C,  3.765,  4.197)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),      (0,), C,  0.999,  1.787)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),      (2,), C,  0.979,  1.181)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),    (0, 1), C,  0.245,  0.246)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),    (1, 2), C,  2.306,  2.717)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192), (0, 1, 2), C,  4.154,  4.467)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),      (0,), C,  1.000,  1.455)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),      (2,), C,  1.026,  1.149)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),    (0, 1), C,  0.327,  0.329)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),    (1, 2), C,  2.499,  2.732)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256), (0, 1, 2), C,  5.483,  5.659)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),      (0,), C,  1.306,  1.847)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),      (2,), C,  0.969,  1.057)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),    (0, 1), C,  0.352,  0.352)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),    (1, 2), C,  2.670,  2.805)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320), (0, 1, 2), C,  6.120,  6.226)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),      (0,), C,  1.000,  0.983)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),      (2,), C,  1.007,  1.112)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),    (0, 1), C,  0.254,  0.255)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),    (1, 2), C,  2.351,  2.585)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128), (0, 1, 2), C,  4.328,  4.464)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),      (0,), C,  1.000,  0.886)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),      (2,), C,  0.993,  1.050)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),    (0, 1), C,  0.287,  0.287)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),    (1, 2), C,  2.592,  2.713)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192), (0, 1, 2), C,  4.754,  4.808)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),      (0,), F,  1.049,  5.428)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),      (2,), F,  1.062,  4.524)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),    (0, 1), F,  1.273,  4.603)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128),    (1, 2), F,  0.385,  0.473)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 128, 128), (0, 1, 2), F,  1.714,  4.035)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),      (0,), F,  1.000,  2.736)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),      (2,), F,  0.974,  2.322)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),    (0, 1), F,  1.378,  3.196)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192),    (1, 2), F,  0.167,  0.177)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 192, 192), (0, 1, 2), F,  1.655,  2.932)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),      (0,), F,  0.956,  2.253)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),      (2,), F,  0.991,  1.884)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),    (0, 1), F,  3.489,  5.467)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256),    (1, 2), F,  0.259,  0.264)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 256, 256), (0, 1, 2), F,  3.024,  4.532)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),      (0,), F,  0.998,  2.327)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),      (2,), F,  0.971,  1.140)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),    (0, 1), F,  4.700,  6.228)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320),    (1, 2), F,  0.251,  0.255)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = (  (512, 320, 320), (0, 1, 2), F,  3.641,  4.497)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),      (0,), F,  1.003,  3.476)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),      (2,), F,  1.008,  2.822)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),    (0, 1), F,  1.076,  2.883)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128),    (1, 2), F,  0.153,  0.164)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 128, 128), (0, 1, 2), F,  1.594,  2.750)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),      (0,), F,  0.965,  2.237)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),      (2,), F,  0.990,  1.920)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),    (0, 1), F,  1.985,  3.096)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192),    (1, 2), F,  0.168,  0.173)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 192, 192), (0, 1, 2), F,  2.022,  2.938)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),      (0,), F,  1.002,  2.355)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),      (2,), F,  1.049,  0.978)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),    (0, 1), F,  4.514,  5.999)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256),    (1, 2), F,  0.245,  0.247)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 256, 256), (0, 1, 2), F,  3.379,  3.994)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),      (0,), F,  0.993,  2.338)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),      (2,), F,  1.004,  0.862)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),    (0, 1), F,  5.701,  6.817)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320),    (1, 2), F,  0.230,  0.232)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (1024, 320, 320), (0, 1, 2), F,  4.039,  4.599)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),      (0,), F,  1.042,  2.408)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),      (2,), F,  0.983,  1.385)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),    (0, 1), F,  1.613,  2.538)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128),    (1, 2), F,  0.187,  0.195)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 128, 128), (0, 1, 2), F,  1.754,  2.299)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),      (0,), F,  0.999,  2.350)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),      (2,), F,  0.987,  1.281)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),    (0, 1), F,  2.328,  3.027)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192),    (1, 2), F,  0.167,  0.169)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 192, 192), (0, 1, 2), F,  2.291,  2.840)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),      (0,), F,  1.000,  2.361)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),      (2,), F,  0.918,  0.750)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),    (0, 1), F,  4.976,  5.834)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256),    (1, 2), F,  0.255,  0.256)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 256, 256), (0, 1, 2), F,  3.773,  4.025)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),      (0,), F,  0.999,  2.369)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),      (2,), F,  0.923,  0.742)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),    (0, 1), F,  6.073,  6.583)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320),    (1, 2), F,  0.241,  0.242)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (2048, 320, 320), (0, 1, 2), F,  4.435,  4.713)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),      (0,), F,  0.993,  2.279)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),      (2,), F,  1.007,  1.110)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),    (0, 1), F,  2.012,  2.929)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128),    (1, 2), F,  0.203,  0.208)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 128, 128), (0, 1, 2), F,  1.991,  2.524)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),      (0,), F,  0.998,  2.320)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),      (2,), F,  0.989,  0.764)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),    (0, 1), F,  2.977,  3.562)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192),    (1, 2), F,  0.194,  0.196)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 192, 192), (0, 1, 2), F,  2.502,  2.650)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),      (0,), F,  0.994,  2.311)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),      (2,), F,  0.990,  0.712)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),    (0, 1), F,  5.511,  6.077)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256),    (1, 2), F,  0.248,  0.249)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 256, 256), (0, 1, 2), F,  4.038,  4.173)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),      (0,), F,  0.997,  2.310)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),      (2,), F,  0.964,  0.520)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),    (0, 1), F,  7.209,  7.505)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320),    (1, 2), F,  0.268,  0.269)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ( (4096, 320, 320), (0, 1, 2), F,  4.288,  4.375)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),      (0,), F,  1.000,  1.557)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),      (2,), F,  1.000,  1.083)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),    (0, 1), F,  2.179,  2.268)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128),    (1, 2), F,  0.182,  0.183)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 128, 128), (0, 1, 2), F,  2.240,  2.302)

	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),      (0,), F,  1.000,  1.555)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),      (2,), F,  1.005,  1.014)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),    (0, 1), F,  2.559,  2.626)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192),    (1, 2), F,  0.180,  0.180)
	(shape, axes, order, speedup (auto plan), speedup (explicit plan)) = ((16000, 192, 192), (0, 1, 2), F,  2.232,  2.599)

@leofang

leofang commented Jan 11, 2019

Copy link
Copy Markdown
Member Author

@grlee77 Would you care for reviewing my changes? An extra pair of eyes would be very helpful, especially since I'm building on top of your PR. Thanks!

@grlee77 grlee77 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some minor comments. Ideally we would extend the planning to the 1D case as well, but that could also be left to a future PR.

Comment thread cupyx/scipy/fftpack/fft.py Resolved
Comment thread cupy/fft/fft.py Resolved
Comment thread cupy/fft/fft.py Resolved
@leofang leofang changed the title [WIP] Adding "plan" argument for multi-dimensional FFT functions in cupyx.scipy.fftpack Adding plan argument for multi-dimensional FFT functions in cupyx.scipy.fftpack Jan 11, 2019
@leofang

leofang commented Jan 11, 2019

Copy link
Copy Markdown
Member Author

Thanks a lot for helping out, @grlee77! One quick reply to your note:

Ideally we would extend the planning to the 1D case as well, but that could also be left to a future PR.

I agree. I will work on the 1D case and create a separate PR after this one is merged. Efficient ND FFT is critical to my work, so I started it first.

@leofang leofang changed the title Adding plan argument for multi-dimensional FFT functions in cupyx.scipy.fftpack Add plan argument for multi-dimensional FFT functions in cupyx.scipy.fftpack Jan 11, 2019
@leofang leofang changed the title Add plan argument for multi-dimensional FFT functions in cupyx.scipy.fftpack Add plan argument for 2D/3D FFT functions in cupyx.scipy.fftpack Jan 12, 2019
@leofang

leofang commented Jan 26, 2019

Copy link
Copy Markdown
Member Author

@asi1024 could you review this PR when you have time please? I would like to push this for our production code, and based on this PR I will also create other PRs, such as making 1D FFT accept cuFFT plans as well. Thanks!

@asi1024

asi1024 commented Jan 29, 2019

Copy link
Copy Markdown
Member

Thank you for the PR and sorry for late response. LGTM!

@asi1024

asi1024 commented Jan 29, 2019

Copy link
Copy Markdown
Member

Jenkins, test this please.

@chainer-ci

Copy link
Copy Markdown
Member

Jenkins CI test (for commit d7272d0, target branch master) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

@leofang leofang changed the title Add plan argument for 2D/3D FFT functions in cupyx.scipy.fftpack Add plan argument to 2D/3D FFT functions in cupyx.scipy.fftpack Jan 31, 2019
@asi1024

asi1024 commented Jan 31, 2019

Copy link
Copy Markdown
Member

Jenkins CI tests are failing for Python2 and we are investigating the cause. Could you hold on until we come back to you with further details?

@leofang

leofang commented Jan 31, 2019

Copy link
Copy Markdown
Member Author

@asi1024 thanks for update! Sure, no worries.

@leofang

leofang commented Feb 5, 2019

Copy link
Copy Markdown
Member Author

@asi1024 any update on the failure?

@leofang

leofang commented Feb 5, 2019

Copy link
Copy Markdown
Member Author

Just realized I also need to update the documentation. It's done in a7803c6.

@asi1024 asi1024 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for late response. Some tests fail in the case of ndim == 4.

import cupy.fft.config as config
config.enable_nd_planning = False # use explicit plan
plan = scp.fftpack.get_fft_plan(x)
out = scp.fftpack.fft2(x, shape=self.s, axes=self.axes, plan=plan)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails when self.s is not None.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, can you be clearer? Does it have to do with ndim == 4 only? And by failure you meant the results don't match, or there's an exception? Thanks!

@leofang leofang Feb 8, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it fail only with explicit plan?

@leofang leofang Feb 9, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asi1024 I need more information from you for reproducing the failure. In my tests I could only tell that when self.s is added, get_fft_plan needs to know the "cooked" shape. This is now supported in commit 00dc0fe I just pushed.

However, I don't think my finding is relevant to the error you saw. I suspect it is caused by this test case:

{'shape': (2, 3, 4, 5), 's': None, 'axes': None},

which asks for transforming 4 axes and so is not supported by the current cuFFT plan_nd implementation by design. The error message would be CUFFT can only transform along 1, 2 or 3 axes, but 4 axes were specified. Am I right? If so, I'll just mark this test case so that when an explicit plan is used we skip this one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test failure is caused by incompatibility between scipy and cupyx.scipy. (Only cupyx raises the error which you wrote.) How about returning None instead of raising ValueError in get_fft_plan?

@leofang leofang Feb 10, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear @asi1024, thanks a lot for your reply and patience! I finally figure out how to do the tests myself using unittest. I can confirm several observations made along this conversion but I also find more, see the summary below. A bug-free commit ef46518 is just pushed.

Here's a list of issues I resolved:

  • self.s needs to be passed to the FFT functions in scipy.fftpack or their CuPy counterparts.
  • when the above is done, the input shape could be changed internally (and so is the output shape) before passing to the underlying FFT library. The cuFFT plan needs to be informed of this.
  • need an assignment when overwrite_x=True, see The overwrite_x argument of FFT functions is deceptive in certain conditions #1988.
  • axes could be None in get_fft_plan().
  • in some cases we cannot generate a cuFFT PlanNd, so in such situations we skip the test, see below.

Now, I can see that sometimes returning None is preferred over raising an exception. However, when PlanNd was implemented (not by me), it was mainly targeting at boosting FFT performance. It is thus expected that people who would call get_fft_plan() are somewhat more advanced users, and they would like to really get a plan to speed up the FFT part in their applications.

With this background, I would tend to object to this design pattern for get_fft_plan() for three reasons:

  1. Returning None will kill the sought-after speedup silently, and users would not know why and would be puzzled for a while until they check the returned plan and find out it's None.
  2. Even if they do the check, there'd be no instruction as for why None was returned. Raising an exception tells them the reason so that they can make necessary changes if possible.
  3. We don't want to change significantly the implantation just to get some tests passed, especially when those tests are explicitly excluded by original design. We only do this if there's a compelling argument.

Therefore, I conclude that our lives would be much simpler if the offending tests are simply skipped. Let me know what you think. If you are convinced please re-run the test for me. Thank you 🙏

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also +1 on not silently returning None instead of a plan. I agree that we should just skip test cases where n-dimensional planning is not possible.

If we want to be able to allow preplanning for these other, more general cases, it would be possible to extend get_fft_plan in the future so that it could return, for example, a list of 1d plans for cases where n-dimensional planning is not possible. The fft functions would then need to also be modified to handle lists of plans in addition to a single plan.

In cupyx.scipy.fftpack the FFT functions support the argument "shape", meaning
that the shape after transfrom could be different from the input's. Now
get_fft_plan() can get this right by mimicking _cook_shape().
@leofang

leofang commented Feb 15, 2019

Copy link
Copy Markdown
Member Author

btw @asi1024 can we tag this PR for v6.0.0b3 if possible? I'd like to push it for production asap since having a cuFFT plan can mitigate a big performance bottleneck I encounter in several of the projects I participate. Thanks!

@asi1024

asi1024 commented Feb 15, 2019

Copy link
Copy Markdown
Member

Jenkins, test this please.

@asi1024 asi1024 added the cat:feature New features/APIs label Feb 15, 2019
@asi1024 asi1024 added this to the v6.0.0b3 milestone Feb 15, 2019
@asi1024

asi1024 commented Feb 15, 2019

Copy link
Copy Markdown
Member

Jenkins, test this please.

@chainer-ci

Copy link
Copy Markdown
Member

Jenkins CI test (for commit be3a11f, target branch master) failed with status FAILURE.
(For contributors, please wait until the reviewer confirms the details of the error.)

@asi1024

asi1024 commented Feb 16, 2019

Copy link
Copy Markdown
Member

Jenkins failure is irrelevant to this PR. LGTM! Thanks!

@asi1024
asi1024 merged commit 4b552b6 into cupy:master Feb 16, 2019
@leofang

leofang commented Feb 16, 2019

Copy link
Copy Markdown
Member Author

Thanks a lot for your help, @asi1024 and @grlee77! I'll make a PR for 1D FFT shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:feature New features/APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants