Skip to content
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

use do-while-0 for check_cuda_error* #476

Merged
merged 1 commit into from
Feb 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions taichi/cuda_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
#include <cuda_runtime_api.h>
#include <driver_types.h>

#define check_cuda_error(err) \
{ \
#define check_cuda_error(err) \
do { \
auto __err = (err); \
if (int(__err)) \
TC_ERROR("Cuda Error {}: {}", get_cuda_error_name(__err), \
get_cuda_error_string(__err)); \
}
} while (0)

#define check_cuda_error_as_warning(err) \
{ \
do { \
auto __err = (err); \
if (int(__err)) \
TC_WARN("Cuda Error {} (treated as warning): {}", \
get_cuda_error_name(__err), get_cuda_error_string(__err)); \
}
} while (0)

TLANG_NAMESPACE_BEGIN

Expand Down