MCPcopy Create free account
hub / github.com/clMathLibraries/clFFT / random_supported_problem_size

Function random_supported_problem_size

src/tests/accuracy_test_random.cpp:113–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111 }
112
113 std::vector<size_t> random_supported_problem_size( size_t dimensions, clfftPrecision precision, clfftLayout layout )
114 {
115 std::vector<size_t> lengths;
116
117 std::vector<size_t> supported_radices;
118 supported_radices.push_back(2);
119 supported_radices.push_back(3);
120 supported_radices.push_back(5);
121 supported_radices.push_back(7);
122
123 // total size of this problem should be some fraction of the total space available on the device
124 size_t this_problem_size = random_int(1, max_problem_size_in_datapoints(precision,layout));
125
126 size_t total_problem_size = 1;
127 std::vector<size_t> factors;
128
129 while( total_problem_size < this_problem_size )
130 {
131 size_t a_factor = supported_radices[random_int(0, supported_radices.size()-1)];
132 if( total_problem_size * a_factor <= this_problem_size )
133 {
134 total_problem_size *= a_factor;
135 factors.push_back(a_factor);
136 }
137 else
138 break;
139 } // problem size is now factored into some permutation of 2s, 3s, and 5s
140 // (exact combination stored in "factors"
141
142 for( size_t i = 0; i < dimensions; ++i )
143 lengths.push_back(1);
144
145 // distribute the values in factors to each valid length value
146 while( !factors.empty() )
147 {
148 size_t which_factor = random_int( 0, factors.size()-1 );
149 size_t dim = random_int( 0, dimensions-1 );
150 lengths[dim] *= factors[which_factor];
151 factors.erase(factors.begin() + which_factor);
152 }
153
154 // by the time we reach the end, we've calculated the total problem size, split it up into valid radices, and
155 // distributed those among the dimensions available
156
157 if( lengths.size() != dimensions )
158 throw std::runtime_error( "random_supported_problem_size: number of lengths does not corroborate number of dimensions" );
159
160 return lengths;
161 }
162
163 struct Parameters {
164 size_t batch_size;

Callers 1

ParametersMethod · 0.85

Calls 3

random_intFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected