Reduce tensor_contract_gpu test.

The original test times out after 60 minutes on Windows, even when
setting flags to optimize for speed.  Reducing the number of
contractions performed from 3600->27 for subtests 8,9 allow the
two to run in just over a minute each.

(cherry picked from commit be9e7d205f38e3e8effdfdded88817b371673930)
This commit is contained in:
Antonio Sanchez 2021-10-01 05:16:30 +00:00
parent 554982beef
commit ac561cd038

View File

@ -25,10 +25,6 @@ typedef Tensor<float, 1>::DimensionPair DimPair;
template<int DataLayout> template<int DataLayout>
void test_gpu_contraction(int m_size, int k_size, int n_size) void test_gpu_contraction(int m_size, int k_size, int n_size)
{ {
std::cout << "Testing for (" << m_size << "," << k_size << "," << n_size << ")" << std::endl;
// with these dimensions, the output has 300 * 140 elements, which is
// more than 30 * 1024, which is the number of threads in blocks on
// a 15 SM GK110 GPU
Tensor<float, 2, DataLayout> t_left(m_size, k_size); Tensor<float, 2, DataLayout> t_left(m_size, k_size);
Tensor<float, 2, DataLayout> t_right(k_size, n_size); Tensor<float, 2, DataLayout> t_right(k_size, n_size);
Tensor<float, 2, DataLayout> t_result(m_size, n_size); Tensor<float, 2, DataLayout> t_result(m_size, n_size);
@ -171,25 +167,45 @@ void test_gpu_contraction_n() {
template<int DataLayout> template<int DataLayout>
void test_gpu_contraction_sizes() { void test_gpu_contraction_sizes() {
int m_sizes[] = { 31, 39, 63, 64, 65, int m_sizes[3][5] = {{ 31, 39, 63, 64, 65},
127, 129, 255, 257 , 511, {127, 129, 255, 257 , 511},
512, 513, 1023, 1024, 1025}; {512, 513, 1023, 1024, 1025}};
int n_sizes[] = { 31, 39, 63, 64, 65, int n_sizes[3][5] = {{ 31, 39, 63, 64, 65},
127, 129, 255, 257, 511, {127, 129, 255, 257, 511},
512, 513, 1023, 1024, 1025}; {512, 513, 1023, 1024, 1025}};
int k_sizes[] = { 31, 39, 63, 64, 65, int k_sizes[3][6] = {{ 31, 39, 63, 64, 65, 95},
95, 96, 127, 129, 255, { 96, 127, 129, 255, 257, 511},
257, 511, 512, 513, 1023, {512, 513, 725, 1023, 1024, 1025}};
1024, 1025};
for (int i = 0; i < 15; i++) { // Some selection of specific cases.
for (int j = 0; j < 15; j++) { // - m changes rows each iteration
for (int k = 0; k < 17; k++) { // - n changes rows each 3 iterations
test_gpu_contraction<DataLayout>(m_sizes[i], n_sizes[j], k_sizes[k]); // - k changes rows each 9 iterations
// - within a row, advance once column each iteration
const int m_cols = 5;
const int n_cols = 5;
const int k_cols = 6;
int m_offset = 0;
int n_offset = 1;
int k_offset = 2;
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
for (int l = 0; l < 3; ++l) {
int m = m_sizes[l][m_offset];
int n = n_sizes[j][n_offset];
int k = k_sizes[i][k_offset];
test_gpu_contraction<DataLayout>(m, n, k);
n_offset = (n_offset + 1) % n_cols;
k_offset = (k_offset + 1) % k_cols;
}
m_offset = (m_offset + 1) % m_cols;
if (j < 2) {
n_offset = (n_offset + n_cols - 3) % n_cols; // Rewind 3.
} }
} }
k_offset = (k_offset + 2 * k_cols - 9) % k_cols; // Rewind 9.
} }
} }