File: hipsolver_datatype2string.cpp

package info (click to toggle)
hipsolver 6.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,096 kB
  • sloc: cpp: 72,703; f90: 8,280; sh: 573; python: 531; ansic: 84; makefile: 51; xml: 10
file content (224 lines) | stat: -rw-r--r-- 6,500 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/* ************************************************************************
 * Copyright (C) 2020-2022 Advanced Micro Devices, Inc. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell cop-
 * ies of the Software, and to permit persons to whom the Software is furnished
 * to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM-
 * PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNE-
 * CTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 *
 * ************************************************************************ */

#include "../include/hipsolver_datatype2string.hpp"

/* ============================================================================================ */
/*  Convert hipsolver constants to lapack char. */

char hipsolver2char_operation(hipsolverOperation_t value)
{
    switch(value)
    {
    case HIPSOLVER_OP_N:
        return 'N';
    case HIPSOLVER_OP_T:
        return 'T';
    case HIPSOLVER_OP_C:
        return 'C';
    default:
        throw std::invalid_argument("Invalid enum");
    }
}

char hipsolver2char_fill(hipsolverFillMode_t value)
{
    switch(value)
    {
    case HIPSOLVER_FILL_MODE_UPPER:
        return 'U';
    case HIPSOLVER_FILL_MODE_LOWER:
        return 'L';
    default:
        throw std::invalid_argument("Invalid enum");
    }
}

char hipsolver2char_side(hipsolverSideMode_t value)
{
    switch(value)
    {
    case HIPSOLVER_SIDE_LEFT:
        return 'L';
    case HIPSOLVER_SIDE_RIGHT:
        return 'R';
    default:
        throw std::invalid_argument("Invalid enum");
    }
}

char hipsolver2char_evect(hipsolverEigMode_t value)
{
    switch(value)
    {
    case HIPSOLVER_EIG_MODE_NOVECTOR:
        return 'N';
    case HIPSOLVER_EIG_MODE_VECTOR:
        return 'V';
    default:
        throw std::invalid_argument("Invalid enum");
    }
}

char hipsolver2char_eform(hipsolverEigType_t value)
{
    switch(value)
    {
    case HIPSOLVER_EIG_TYPE_1:
        return '1';
    case HIPSOLVER_EIG_TYPE_2:
        return '2';
    case HIPSOLVER_EIG_TYPE_3:
        return '3';
    default:
        throw std::invalid_argument("Invalid enum");
    }
}

char hipsolver2char_erange(hipsolverEigRange_t value)
{
    switch(value)
    {
    case HIPSOLVER_EIG_RANGE_ALL:
        return 'A';
    case HIPSOLVER_EIG_RANGE_V:
        return 'V';
    case HIPSOLVER_EIG_RANGE_I:
        return 'I';
    default:
        throw std::invalid_argument("Invalid enum");
    }
}

/* ============================================================================================ */
/*  Convert lapack char constants to hipsolver type. */

hipsolverStatus_t string2hipsolver_status(const std::string& value)
{
    return value == "HIPSOLVER_STATUS_SUCCESS"             ? HIPSOLVER_STATUS_SUCCESS
           : value == "HIPSOLVER_STATUS_NOT_INITIALIZED"   ? HIPSOLVER_STATUS_NOT_INITIALIZED
           : value == "HIPSOLVER_STATUS_ALLOC_FAILED"      ? HIPSOLVER_STATUS_ALLOC_FAILED
           : value == "HIPSOLVER_STATUS_INVALID_VALUE"     ? HIPSOLVER_STATUS_INVALID_VALUE
           : value == "HIPSOLVER_STATUS_MAPPING_ERROR"     ? HIPSOLVER_STATUS_MAPPING_ERROR
           : value == "HIPSOLVER_STATUS_EXECUTION_FAILED"  ? HIPSOLVER_STATUS_EXECUTION_FAILED
           : value == "HIPSOLVER_STATUS_INTERNAL_ERROR"    ? HIPSOLVER_STATUS_INTERNAL_ERROR
           : value == "HIPSOLVER_STATUS_NOT_SUPPORTED"     ? HIPSOLVER_STATUS_NOT_SUPPORTED
           : value == "HIPSOLVER_STATUS_ARCH_MISMATCH"     ? HIPSOLVER_STATUS_ARCH_MISMATCH
           : value == "HIPSOLVER_STATUS_HANDLE_IS_NULLPTR" ? HIPSOLVER_STATUS_HANDLE_IS_NULLPTR
           : value == "HIPSOLVER_STATUS_INVALID_ENUM"      ? HIPSOLVER_STATUS_INVALID_ENUM
           : value == "HIPSOLVER_STATUS_UNKNOWN"           ? HIPSOLVER_STATUS_UNKNOWN
                                                           : static_cast<hipsolverStatus_t>(-1);
}

hipsolverOperation_t char2hipsolver_operation(char value)
{
    switch(value)
    {
    case 'n':
    case 'N':
        return HIPSOLVER_OP_N;
    case 't':
    case 'T':
        return HIPSOLVER_OP_T;
    case 'c':
    case 'C':
        return HIPSOLVER_OP_C;
    default:
        throw std::invalid_argument("Invalid character");
    }
}

hipsolverFillMode_t char2hipsolver_fill(char value)
{
    switch(value)
    {
    case 'u':
    case 'U':
        return HIPSOLVER_FILL_MODE_UPPER;
    case 'l':
    case 'L':
        return HIPSOLVER_FILL_MODE_LOWER;
    default:
        throw std::invalid_argument("Invalid character");
    }
}

hipsolverSideMode_t char2hipsolver_side(char value)
{
    switch(value)
    {
    case 'l':
    case 'L':
        return HIPSOLVER_SIDE_LEFT;
    case 'r':
    case 'R':
        return HIPSOLVER_SIDE_RIGHT;
    default:
        throw std::invalid_argument("Invalid character");
    }
}

hipsolverEigMode_t char2hipsolver_evect(char value)
{
    switch(value)
    {
    case 'n':
    case 'N':
        return HIPSOLVER_EIG_MODE_NOVECTOR;
    case 'v':
    case 'V':
        return HIPSOLVER_EIG_MODE_VECTOR;
    default:
        throw std::invalid_argument("Invalid character");
    }
}

hipsolverEigType_t char2hipsolver_eform(char value)
{
    switch(value)
    {
    case '1':
        return HIPSOLVER_EIG_TYPE_1;
    case '2':
        return HIPSOLVER_EIG_TYPE_2;
    case '3':
        return HIPSOLVER_EIG_TYPE_3;
    default:
        throw std::invalid_argument("Invalid character");
    }
}

hipsolverEigRange_t char2hipsolver_erange(char value)
{
    switch(value)
    {
    case 'A':
        return HIPSOLVER_EIG_RANGE_ALL;
    case 'V':
        return HIPSOLVER_EIG_RANGE_V;
    case 'I':
        return HIPSOLVER_EIG_RANGE_I;
    default:
        throw std::invalid_argument("Invalid character");
    }
}