}
# endif
+/**
+ * An assertion that checks that the kernel was launched and executed
+ * successfully.
+ *
+ * @note This and similar macro names are examples of preprocessor definitions
+ * in the deal.II library that are not prefixed by a string that likely makes
+ * them unique to deal.II. As a consequence, it is possible that other
+ * libraries your code interfaces with define the same name, and the result
+ * will be name collisions (see
+ * https://en.wikipedia.org/wiki/Name_collision). One can <code>\#undef</code>
+ * this macro, as well as all other macros defined by deal.II that are not
+ * prefixed with either <code>DEAL</code> or <code>deal</code>, by including
+ * the header <code>deal.II/base/undefine_macros.h</code> after all other
+ * deal.II headers have been included.
+ *
+ * @ingroup Exceptions
+ * @author Bruno Turcksin, 2020
+ */
+# ifdef DEBUG
+# define AssertCudaKernel() \
+ { \
+ cudaError_t local_error_code = cudaPeekAtLastError(); \
+ AssertCuda(local_error_code); \
+ local_error_code = cudaDeviceSynchronize(); \
+ AssertCuda(local_error_code) \
+ }
+# else
+# define AssertCudaKernel() \
+ {}
+# endif
+
/**
* An assertion that checks that the error code produced by calling a cuSPARSE
* routine is equal to CUSPARSE_STATUS_SUCCESS.
# undef AssertCuda
#endif // #ifdef AssertCuda
+#ifdef AssertCudaKernel
+# undef AssertCudaKernel
+#endif // #ifdef AssertCudaKernel
+
#ifdef AssertCusolver
# undef AssertCusolver
#endif // #ifdef AssertCusolver
const int n_blocks = 1 + (n_constraints - 1) / CUDAWrappers::block_size;
set_zero_kernel<<<n_blocks, CUDAWrappers::block_size>>>(
constrained_local_dofs_device, n_constraints, vec.get_values());
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
Utilities::CUDA::free(constrained_local_dofs_device);
1 + (n_local_elements - 1) / CUDAWrappers::block_size;
set_initial_guess_kernel<<<n_blocks, CUDAWrappers::block_size>>>(
first_local_range, n_local_elements, vector.get_values());
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
const Number mean_value = vector.mean_value();
vector.add(-mean_value);
const int n_blocks = 1 + size / (chunk_size * block_size);
::dealii::LinearAlgebra::CUDAWrappers::kernel::set<Number>
<<<n_blocks, block_size>>>(data.values_dev.get(), s, size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static void
1.,
v_data.values_dev.get(),
size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static void
-1.,
v_data.values_dev.get(),
size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static void
const int n_blocks = 1 + size / (chunk_size * block_size);
::dealii::LinearAlgebra::CUDAWrappers::kernel::vec_add<Number>
<<<n_blocks, block_size>>>(data.values_dev.get(), a, size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static void
a,
v_data.values_dev.get(),
size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static void
b,
w_data.values_dev.get(),
size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static void
::dealii::LinearAlgebra::CUDAWrappers::kernel::sadd<Number>
<<<dim3(n_blocks, 1), dim3(block_size)>>>(
x, data.values_dev.get(), 1., v_data.values_dev.get(), size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static void
::dealii::LinearAlgebra::CUDAWrappers::kernel::sadd<Number>
<<<dim3(n_blocks, 1), dim3(block_size)>>>(
x, data.values_dev.get(), a, v_data.values_dev.get(), size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static void
b,
w_data.values_dev.get(),
size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static void
const int n_blocks = 1 + size / (chunk_size * block_size);
::dealii::LinearAlgebra::CUDAWrappers::kernel::vec_scale<Number>
<<<n_blocks, block_size>>>(data.values_dev.get(), factor, size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static void
<<<dim3(n_blocks, 1), dim3(block_size)>>>(data.values_dev.get(),
v_data.values_dev.get(),
size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static void
a,
v_data.values_dev.get(),
size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static void
b,
w_data.values_dev.get(),
size);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
static Number
v_data.values_dev.get(),
static_cast<unsigned int>(
size));
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
// Copy the result back to the host
Number result;
const int n_blocks = 1 + (nnz - 1) / block_size;
internal::scale<Number>
<<<n_blocks, block_size>>>(val_dev.get(), factor, nnz);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
return *this;
}
const int n_blocks = 1 + (nnz - 1) / block_size;
internal::scale<Number>
<<<n_blocks, block_size>>>(val_dev.get(), 1. / factor, nnz);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
return *this;
}
column_index_dev.get(),
row_ptr_dev.get(),
column_sums.get_values());
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
return column_sums.linfty_norm();
}
column_index_dev.get(),
row_ptr_dev.get(),
row_sums.get_values());
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
return row_sums.linfty_norm();
}
kernel::vector_bin_op<Number, kernel::Binop_Addition>
<<<n_blocks, block_size>>>(val.get(), tmp, n_elements);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
// Delete the temporary vector
Utilities::CUDA::free(tmp);
const int n_blocks = 1 + (n_elements - 1) / (chunk_size * block_size);
kernel::vec_scale<Number>
<<<n_blocks, block_size>>>(val.get(), factor, n_elements);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
return *this;
}
const int n_blocks = 1 + (n_elements - 1) / (chunk_size * block_size);
kernel::vec_scale<Number>
<<<n_blocks, block_size>>>(val.get(), 1. / factor, n_elements);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
return *this;
}
kernel::vector_bin_op<Number, kernel::Binop_Addition>
<<<n_blocks, block_size>>>(val.get(), down_V.val.get(), n_elements);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
return *this;
}
kernel::vector_bin_op<Number, kernel::Binop_Subtraction>
<<<n_blocks, block_size>>>(val.get(), down_V.val.get(), n_elements);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
return *this;
}
const int n_blocks = 1 + (n_elements - 1) / (chunk_size * block_size);
kernel::vec_add<Number>
<<<n_blocks, block_size>>>(val.get(), a, n_elements);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
const int n_blocks = 1 + (n_elements - 1) / (chunk_size * block_size);
kernel::add_aV<Number><<<dim3(n_blocks, 1), dim3(block_size)>>>(
val.get(), a, down_V.val.get(), n_elements);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
const int n_blocks = 1 + (n_elements - 1) / (chunk_size * block_size);
kernel::add_aVbW<Number><<<dim3(n_blocks, 1), dim3(block_size)>>>(
val.get(), a, down_V.val.get(), b, down_W.val.get(), n_elements);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
const int n_blocks = 1 + (n_elements - 1) / (chunk_size * block_size);
kernel::sadd<Number><<<dim3(n_blocks, 1), dim3(block_size)>>>(
s, val.get(), a, down_V.val.get(), n_elements);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
const int n_blocks = 1 + (n_elements - 1) / (chunk_size * block_size);
kernel::scale<Number><<<dim3(n_blocks, 1), dim3(block_size)>>>(
val.get(), down_scaling_factors.val.get(), n_elements);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}
const int n_blocks = 1 + (n_elements - 1) / (chunk_size * block_size);
kernel::equ<Number><<<dim3(n_blocks, 1), dim3(block_size)>>>(
val.get(), a, down_V.val.get(), n_elements);
-
-# ifdef DEBUG
- // Check that the kernel was launched correctly
- AssertCuda(cudaPeekAtLastError());
- // Check that there was no problem during the execution of the kernel
- AssertCuda(cudaDeviceSynchronize());
-# endif
+ AssertCudaKernel();
}