Apollo  6.0
Open source self driving car software
common.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
17 #pragma once
18 
19 #include <cassert>
20 
21 #if USE_GPU == 1
22 
23 #include <cublas_v2.h>
24 #include <cuda_runtime.h>
25 
26 #endif
27 
28 namespace apollo {
29 namespace perception {
30 namespace base {
31 
32 #ifndef NO_GPU
33 #define NO_GPU assert(false)
34 #endif
35 
36 #if USE_GPU == 1
37 
38 #define BASE_CUDA_CHECK(condition) \
39  { apollo::perception::base::GPUAssert((condition), __FILE__, __LINE__); }
40 
41 inline void GPUAssert(cudaError_t code, const char *file, int line,
42  bool abort = true) {
43  if (code != cudaSuccess) {
44  fprintf(stderr, "GPUassert: %s %s %d\n", cudaGetErrorString(code), file,
45  line);
46  if (abort) {
47  exit(code);
48  }
49  }
50 }
51 
52 #endif
53 
54 } // namespace base
55 } // namespace perception
56 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
void GPUAssert(cudaError_t code, const char *file, int line, bool abort=true)
Definition: common.h:61