Arcane  v4.1.1.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
CudaAccelerator.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* CudaAccelerator.cc (C) 2000-2025 */
9/* */
10/* Backend 'CUDA' pour les accélérateurs. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/accelerator_native/CudaAccelerator.h"
15#include "arccore/base/FatalErrorException.h"
16
17#include <iostream>
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane::Accelerator::Cuda
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28void arcaneCheckCudaErrors(const TraceInfo& ti, cudaError_t e)
29{
30 ARCCORE_FATAL_IF((e!=cudaSuccess), "CUDA Error trace={0} e={1} str={2}", ti, e, cudaGetErrorString(e));
31}
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36void arcaneCheckCudaErrorsNoThrow(const TraceInfo& ti, cudaError_t e)
37{
38 if (e == cudaSuccess)
39 return;
40 String str = String::format("CUDA Error trace={0} e={1} str={2}", ti, e, cudaGetErrorString(e));
41 FatalErrorException ex(ti, str);
42 ex.write(std::cerr);
43}
44
45/*---------------------------------------------------------------------------*/
46/*---------------------------------------------------------------------------*/
47
48} // namespace Arcane::Accelerator::Cuda
49
50/*---------------------------------------------------------------------------*/
51/*---------------------------------------------------------------------------*/