[FEA] Add cuFFT helpers
Open
Nobody has claimed this yet.
inactive-30d
inactive-90d
- Dominant language
- Cuda
- Stars
- 1k
- Forks
- 251
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 31
Description
Spawned from this cuML PR comment: https://github.com/rapidsai/cuml/pull/3058#discussion_r518439663
That PR adds the below code, which would be useful in raft.
#include <cufft.h>
#include <raft/error.hpp>
namespace raft {
/**
* @brief Exception thrown when a cuFFT error is encountered.
*/
struct cufft_error : public raft::exception {
explicit cufft_error(char const* const message) : raft::exception(message) {}
explicit cufft_error(std::string const& message) : raft::exception(message) {}
};
const char* getCufftErrStr(cufftResult status) {
// https://docs.nvidia.com/cuda/cufft/index.html#cufftresult
switch (status) {
case CUFFT_SUCCESS:
return "The cuFFT operation was successful.";
case CUFFT_INVALID_PLAN:
return "cuFFT was passed an invalid plan handle.";
case CUFFT_ALLOC_FAILED:
return "cuFFT failed to allocate GPU or CPU memory.";
case CUFFT_INVALID_VALUE:
return "User specified an invalid pointer or parameter.";
case CUFFT_INTERNAL_ERROR:
return "Driver or internal cuFFT library error.";
case CUFFT_EXEC_FAILED:
return "Failed to execute an FFT on the GPU.";
case CUFFT_SETUP_FAILED:
return "The cuFFT library failed to initialize.";
case CUFFT_INVALID_SIZE:
return "User specified an invalid transform size.";
case CUFFT_INCOMPLETE_PARAMETER_LIST:
return "Missing parameters in call.";
case CUFFT_INVALID_DEVICE:
return "Execution of a plan was on different GPU than plan creation.";
case CUFFT_PARSE_ERROR:
return "Internal plan database error.";
case CUFFT_NO_WORKSPACE:
return "No workspace has been provided prior to plan execution.";
case CUFFT_NOT_IMPLEMENTED:
return "Function does not implement functionality for parameters given.";
case CUFFT_NOT_SUPPORTED:
return "Operation is not supported for parameters given.";
default:
return "Unknown error.";
}
}
/**
* @brief Error checking macro for cuFFT functions.
*
* Invokes a cuFFT function. If the call does not return CUFFT_SUCCESS, throws
* an exception detailing the error that occurred.
*/
#define CUFFT_TRY(call) \
do { \
const cufftResult status = call; \
if (status != CUFFT_SUCCESS) { \
std::string msg{}; \
SET_ERROR_MSG(msg, \
"cuFFT error encountered at: ", "call='%s', Reason=%s", \
#call, raft::getCufftErrStr(status)); \
throw raft::cufft_error(msg); \
} \
} while (0)
class CuFFTHandle {
public:
CuFFTHandle() { CUFFT_TRY(cufftCreate(&handle)); }
~CuFFTHandle() { cufftDestroy(handle); }
operator cufftHandle() const { return handle; }
private:
cufftHandle handle;
};
} // namespace raft
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the cuML PR comment referenced in the issue, then inspect how RAFT currently handles errors and resource-owning helpers. The issue's example names cufft.h and raft/error.hpp; done means the proposed cuFFT error handling and CuFFTHandle helper are integrated into RAFT consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- hpc
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100