Skip to content

Ensure query and info functions do not fail if there is no device #2678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2020

Conversation

umar456
Copy link
Member

@umar456 umar456 commented Nov 24, 2019

Some of the info and query functions failed when called on a system
with no OpenCL runtime or graphics drivers installed. These functions
should be resilient to these situations and provide feed back to the
user about possible next steps. The following functions are able to
function even if there is not device or driver installed.

af_info
af_info_string
af_get_device_count
af_get_size_of
af_get_backend_count
af_get_version
af_get_revision

This also includes their respective C++ functions.

Added unit tests.

@umar456 umar456 requested a review from 9prady9 November 24, 2019 03:19
Copy link
Member

@9prady9 9prady9 left a comment

Choose a reason for hiding this comment

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

Are you sure we can guarantee noexcept for get*** functions as they seem to use std::string extensively and it's constructor is not noexcept and it can throw ?

Update: @umar456 My bad, I misunderstood expect that it is an absolute guarantee that a function wouldn't fail. A non-throwing function can definitely call other throwing functions if the logic cannot handle such a failure such as alloc failures in which case terminate will be called and we are fine for those cases.

AF_TRACE("Found {} CUDA devices", nDevices);
if (nDevices == 0) {
AF_ERROR("No CUDA capable devices found", AF_ERR_DRIVER);
return;
Copy link
Member

Choose a reason for hiding this comment

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

nit: return valid and won't hurt, but we can remove it.

for (int i = 0; i < nDevices; i++) {
cudaDevice_t dev;
CUDA_CHECK(cudaGetDeviceProperties(&dev.prop, i));
if (dev.prop.major < getMinSupportedCompute(cudaMajorVer)) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we do a similar check in setDevice ?

"ICD from your device vendor. You can use the clinfo utility "
"to debug OpenCL installation issues.",
AF_ERR_RUNTIME);
}
Copy link
Member

Choose a reason for hiding this comment

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

Surprising that we didn't have any error reporting when no platforms are found.

@umar456 umar456 force-pushed the nodevice branch 2 times, most recently from cc5d067 to ab24400 Compare January 30, 2020 19:31
Some of the info and query functions failed when called on a system
with no OpenCL runtime or graphics drivers installed. These functions
should be resilient to these situations and provide feed back to the
user about possible next steps. The following functions are able to
function even if there is not device or driver installed.

af_info
af_info_string
af_get_device_count
af_get_size_of
af_get_backend_count
af_get_version
af_get_revision

This also includes their respective C++ functions.

Added unit tests.
@umar456 umar456 merged commit 8ce5778 into arrayfire:master Jan 31, 2020
@umar456 umar456 deleted the nodevice branch January 31, 2020 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants