Skip to content

Commit

Permalink
Fix check for determining if problem size fits in device memory
Browse files Browse the repository at this point in the history
* Check free and total memory in vram check.
* Include number of buffers needed in problem size calculation.
  • Loading branch information
malcolmroberts committed May 28, 2020
1 parent 008f4ae commit 4192227
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
14 changes: 12 additions & 2 deletions clients/tests/accuracy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,19 @@ void rocfft_transform(const std::vector<size_t>
const size_t isize_t = var_size(precision, itype);
const size_t osize_t = var_size(precision, otype);

// Numbers of input and output buffers:
const int nibuffer
= (itype == rocfft_array_type_complex_planar || itype == rocfft_array_type_hermitian_planar)
? 2
: 1;
const int nobuffer
= (otype == rocfft_array_type_complex_planar || otype == rocfft_array_type_hermitian_planar)
? 2
: 1;

// Check if the problem fits on the device; if it doesn't skip it.
if(!vram_fits_problem(isize * isize_t,
(place == rocfft_placement_inplace) ? 0 : osize * osize_t,
if(!vram_fits_problem(nibuffer * isize * isize_t,
(place == rocfft_placement_inplace) ? 0 : nobuffer * osize * osize_t,
workbuffersize))
{
rocfft_plan_destroy(gpu_plan);
Expand Down
27 changes: 26 additions & 1 deletion clients/tests/rocfft_against_fftw.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,35 @@ inline rocfft_precision precision_selector<double>()
inline bool
vram_fits_problem(const size_t isize, const size_t osize, const size_t wsize, int deviceId = 0)
{
const size_t prob_size = isize + osize + wsize;

// Check device total memory:
hipDeviceProp_t prop;
auto retval = hipGetDeviceProperties(&prop, deviceId);
assert(retval == hipSuccess);
return prop.totalGlobalMem > isize + osize + wsize;

if(prop.totalGlobalMem < prob_size)
{
return false;
}

// Check free and total available memory:
size_t free = 0;
size_t total = 0;
retval = hipMemGetInfo(&free, &total);
assert(retval == hipSuccess);

if(total < prob_size)
{
return false;
}

if(free < prob_size)
{
return false;
}

return true;
}

// Perform and out-of-place computation on contiguous data and then return this in an
Expand Down

0 comments on commit 4192227

Please sign in to comment.