2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2014,2015,2016,2017,2018 by the GROMACS development team.
5 * Copyright (c) 2019,2020,2021, by the GROMACS development team, led by
6 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7 * and including many others, as listed in the AUTHORS file in the
8 * top-level source directory and at http://www.gromacs.org.
10 * GROMACS is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1
13 * of the License, or (at your option) any later version.
15 * GROMACS is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with GROMACS; if not, see
22 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * If you want to redistribute modifications to GROMACS, please
26 * consider that scientific software is very special. Version
27 * control is crucial - bugs must be traceable. We will be happy to
28 * consider code for inclusion in the official distribution, but
29 * derived work must not be called official GROMACS. Details are found
30 * in the README & COPYING files - if they are missing, get the
31 * official version at http://www.gromacs.org.
33 * To help us fund GROMACS development, we humbly ask that you cite
34 * the research papers on the package. Check out http://www.gromacs.org.
37 * \brief Define utility routines for OpenCL
39 * \author Anca Hamuraru <anca@streamcomputing.eu>
52 #include "gromacs/gpu_utils/gpu_utils.h"
55 /*! \brief Convert error code to diagnostic string */
56 std::string ocl_get_error_string(cl_int error)
60 // run-time and JIT compiler errors
61 case 0: return "CL_SUCCESS";
62 case -1: return "CL_DEVICE_NOT_FOUND";
63 case -2: return "CL_DEVICE_NOT_AVAILABLE";
64 case -3: return "CL_COMPILER_NOT_AVAILABLE";
65 case -4: return "CL_MEM_OBJECT_ALLOCATION_FAILURE";
66 case -5: return "CL_OUT_OF_RESOURCES";
67 case -6: return "CL_OUT_OF_HOST_MEMORY";
68 case -7: return "CL_PROFILING_INFO_NOT_AVAILABLE";
69 case -8: return "CL_MEM_COPY_OVERLAP";
70 case -9: return "CL_IMAGE_FORMAT_MISMATCH";
71 case -10: return "CL_IMAGE_FORMAT_NOT_SUPPORTED";
72 case -11: return "CL_BUILD_PROGRAM_FAILURE";
73 case -12: return "CL_MAP_FAILURE";
74 case -13: return "CL_MISALIGNED_SUB_BUFFER_OFFSET";
75 case -14: return "CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST";
76 case -15: return "CL_COMPILE_PROGRAM_FAILURE";
77 case -16: return "CL_LINKER_NOT_AVAILABLE";
78 case -17: return "CL_LINK_PROGRAM_FAILURE";
79 case -18: return "CL_DEVICE_PARTITION_FAILED";
80 case -19: return "CL_KERNEL_ARG_INFO_NOT_AVAILABLE";
82 // compile-time errors
83 case -30: return "CL_INVALID_VALUE";
84 case -31: return "CL_INVALID_DEVICE_TYPE";
85 case -32: return "CL_INVALID_PLATFORM";
86 case -33: return "CL_INVALID_DEVICE";
87 case -34: return "CL_INVALID_CONTEXT";
88 case -35: return "CL_INVALID_QUEUE_PROPERTIES";
89 case -36: return "CL_INVALID_COMMAND_QUEUE";
90 case -37: return "CL_INVALID_HOST_PTR";
91 case -38: return "CL_INVALID_MEM_OBJECT";
92 case -39: return "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR";
93 case -40: return "CL_INVALID_IMAGE_SIZE";
94 case -41: return "CL_INVALID_SAMPLER";
95 case -42: return "CL_INVALID_BINARY";
96 case -43: return "CL_INVALID_BUILD_OPTIONS";
97 case -44: return "CL_INVALID_PROGRAM";
98 case -45: return "CL_INVALID_PROGRAM_EXECUTABLE";
99 case -46: return "CL_INVALID_KERNEL_NAME";
100 case -47: return "CL_INVALID_KERNEL_DEFINITION";
101 case -48: return "CL_INVALID_KERNEL";
102 case -49: return "CL_INVALID_ARG_INDEX";
103 case -50: return "CL_INVALID_ARG_VALUE";
104 case -51: return "CL_INVALID_ARG_SIZE";
105 case -52: return "CL_INVALID_KERNEL_ARGS";
106 case -53: return "CL_INVALID_WORK_DIMENSION";
107 case -54: return "CL_INVALID_WORK_GROUP_SIZE";
108 case -55: return "CL_INVALID_WORK_ITEM_SIZE";
109 case -56: return "CL_INVALID_GLOBAL_OFFSET";
110 case -57: return "CL_INVALID_EVENT_WAIT_LIST";
111 case -58: return "CL_INVALID_EVENT";
112 case -59: return "CL_INVALID_OPERATION";
113 case -60: return "CL_INVALID_GL_OBJECT";
114 case -61: return "CL_INVALID_BUFFER_SIZE";
115 case -62: return "CL_INVALID_MIP_LEVEL";
116 case -63: return "CL_INVALID_GLOBAL_WORK_SIZE";
117 case -64: return "CL_INVALID_PROPERTY";
118 case -65: return "CL_INVALID_IMAGE_DESCRIPTOR";
119 case -66: return "CL_INVALID_COMPILER_OPTIONS";
120 case -67: return "CL_INVALID_LINKER_OPTIONS";
121 case -68: return "CL_INVALID_DEVICE_PARTITION_COUNT";
124 case -1000: return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR";
125 case -1001: return "CL_PLATFORM_NOT_FOUND_KHR";
126 case -1002: return "CL_INVALID_D3D10_DEVICE_KHR";
127 case -1003: return "CL_INVALID_D3D10_RESOURCE_KHR";
128 case -1004: return "CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR";
129 case -1005: return "CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR";
130 default: return "Unknown OpenCL error: " + std::to_string(static_cast<int32_t>(error));