Skip to content

Commit b794dd0

Browse files
committed
Enum and macro
1 parent 9045916 commit b794dd0

4 files changed

Lines changed: 93 additions & 292 deletions

File tree

backends/hip/gen_hip_library.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,22 @@ def print_struct(name, struct)
6767
print_struct_with_namespace(:HIP, name, struct, prepends: prepends)
6868
end
6969

70+
typedef_enum_names = $all_types.filter_map { |t| t.type.name if t.type.is_a?(YAMLCAst::Enum) }.to_set
71+
$all_enums.each do |e|
72+
next unless e.name
73+
next if typedef_enum_names.include?(e.name)
74+
75+
print_enum(e.name, e)
76+
end
77+
7078
$all_types.each do |t|
7179
if t.type.is_a? YAMLCAst::Enum
7280
enum = $all_enums.find { |e| t.type.name == e.name }
7381
print_enum(t.name, enum)
7482
elsif $objects.include?(t.name)
7583
print_hip_object(t.name)
7684
elsif t.type.is_a? YAMLCAst::Struct
77-
struct = $all_structs.find { |s| t.type.name == s.name }
85+
struct = t.type.name ? $all_structs.find { |s| t.type.name == s.name } : t.type
7886
next unless struct
7987

8088
print_struct(t.name, struct)

backends/hip/headers.patch

Lines changed: 4 additions & 266 deletions
Original file line numberDiff line numberDiff line change
@@ -1,167 +1,6 @@
1-
diff -u4 -r --new-file include/hip/amd_detail/amd_hip_vector_types.h modified_include/hip/amd_detail/amd_hip_vector_types.h
2-
--- include/hip/amd_detail/amd_hip_vector_types.h 2026-03-27 20:57:07.000000000 +0000
3-
+++ modified_include/hip/amd_detail/amd_hip_vector_types.h 2026-03-30 22:25:53.000000000 +0000
4-
@@ -1384,20 +1384,20 @@
5-
T w;\
6-
} CUDA_name##4;
7-
#endif
8-
9-
-__MAKE_VECTOR_TYPE__(uchar, unsigned char);
10-
-__MAKE_VECTOR_TYPE__(char, char);
11-
-__MAKE_VECTOR_TYPE__(ushort, unsigned short);
12-
-__MAKE_VECTOR_TYPE__(short, short);
13-
-__MAKE_VECTOR_TYPE__(uint, unsigned int);
14-
-__MAKE_VECTOR_TYPE__(int, int);
15-
-__MAKE_VECTOR_TYPE__(ulong, unsigned long);
16-
-__MAKE_VECTOR_TYPE__(long, long);
17-
-__MAKE_VECTOR_TYPE__(ulonglong, unsigned long long);
18-
-__MAKE_VECTOR_TYPE__(longlong, long long);
19-
-__MAKE_VECTOR_TYPE__(float, float);
20-
-__MAKE_VECTOR_TYPE__(double, double);
21-
+__MAKE_VECTOR_TYPE__(uchar, unsigned char)
22-
+__MAKE_VECTOR_TYPE__(char, char)
23-
+__MAKE_VECTOR_TYPE__(ushort, unsigned short)
24-
+__MAKE_VECTOR_TYPE__(short, short)
25-
+__MAKE_VECTOR_TYPE__(uint, unsigned int)
26-
+__MAKE_VECTOR_TYPE__(int, int)
27-
+__MAKE_VECTOR_TYPE__(ulong, unsigned long)
28-
+__MAKE_VECTOR_TYPE__(long, long)
29-
+__MAKE_VECTOR_TYPE__(ulonglong, unsigned long long)
30-
+__MAKE_VECTOR_TYPE__(longlong, long long)
31-
+__MAKE_VECTOR_TYPE__(float, float)
32-
+__MAKE_VECTOR_TYPE__(double, double)
33-
34-
#else // !defined(__has_attribute)
35-
36-
#if defined(_MSC_VER)
37-
@@ -2478,65 +2478,65 @@
38-
return r; \
39-
}
40-
#endif
41-
42-
-DECLOP_MAKE_ONE_COMPONENT(unsigned char, uchar1);
43-
-DECLOP_MAKE_TWO_COMPONENT(unsigned char, uchar2);
44-
-DECLOP_MAKE_THREE_COMPONENT(unsigned char, uchar3);
45-
-DECLOP_MAKE_FOUR_COMPONENT(unsigned char, uchar4);
46-
-
47-
-DECLOP_MAKE_ONE_COMPONENT(signed char, char1);
48-
-DECLOP_MAKE_TWO_COMPONENT(signed char, char2);
49-
-DECLOP_MAKE_THREE_COMPONENT(signed char, char3);
50-
-DECLOP_MAKE_FOUR_COMPONENT(signed char, char4);
51-
-
52-
-DECLOP_MAKE_ONE_COMPONENT(unsigned short, ushort1);
53-
-DECLOP_MAKE_TWO_COMPONENT(unsigned short, ushort2);
54-
-DECLOP_MAKE_THREE_COMPONENT(unsigned short, ushort3);
55-
-DECLOP_MAKE_FOUR_COMPONENT(unsigned short, ushort4);
56-
-
57-
-DECLOP_MAKE_ONE_COMPONENT(signed short, short1);
58-
-DECLOP_MAKE_TWO_COMPONENT(signed short, short2);
59-
-DECLOP_MAKE_THREE_COMPONENT(signed short, short3);
60-
-DECLOP_MAKE_FOUR_COMPONENT(signed short, short4);
61-
-
62-
-DECLOP_MAKE_ONE_COMPONENT(unsigned int, uint1);
63-
-DECLOP_MAKE_TWO_COMPONENT(unsigned int, uint2);
64-
-DECLOP_MAKE_THREE_COMPONENT(unsigned int, uint3);
65-
-DECLOP_MAKE_FOUR_COMPONENT(unsigned int, uint4);
66-
-
67-
-DECLOP_MAKE_ONE_COMPONENT(signed int, int1);
68-
-DECLOP_MAKE_TWO_COMPONENT(signed int, int2);
69-
-DECLOP_MAKE_THREE_COMPONENT(signed int, int3);
70-
-DECLOP_MAKE_FOUR_COMPONENT(signed int, int4);
71-
-
72-
-DECLOP_MAKE_ONE_COMPONENT(float, float1);
73-
-DECLOP_MAKE_TWO_COMPONENT(float, float2);
74-
-DECLOP_MAKE_THREE_COMPONENT(float, float3);
75-
-DECLOP_MAKE_FOUR_COMPONENT(float, float4);
76-
-
77-
-DECLOP_MAKE_ONE_COMPONENT(double, double1);
78-
-DECLOP_MAKE_TWO_COMPONENT(double, double2);
79-
-DECLOP_MAKE_THREE_COMPONENT(double, double3);
80-
-DECLOP_MAKE_FOUR_COMPONENT(double, double4);
81-
-
82-
-DECLOP_MAKE_ONE_COMPONENT(unsigned long, ulong1);
83-
-DECLOP_MAKE_TWO_COMPONENT(unsigned long, ulong2);
84-
-DECLOP_MAKE_THREE_COMPONENT(unsigned long, ulong3);
85-
-DECLOP_MAKE_FOUR_COMPONENT(unsigned long, ulong4);
86-
-
87-
-DECLOP_MAKE_ONE_COMPONENT(signed long, long1);
88-
-DECLOP_MAKE_TWO_COMPONENT(signed long, long2);
89-
-DECLOP_MAKE_THREE_COMPONENT(signed long, long3);
90-
-DECLOP_MAKE_FOUR_COMPONENT(signed long, long4);
91-
-
92-
-DECLOP_MAKE_ONE_COMPONENT(unsigned long long, ulonglong1);
93-
-DECLOP_MAKE_TWO_COMPONENT(unsigned long long, ulonglong2);
94-
-DECLOP_MAKE_THREE_COMPONENT(unsigned long long, ulonglong3);
95-
-DECLOP_MAKE_FOUR_COMPONENT(unsigned long long, ulonglong4);
96-
-
97-
-DECLOP_MAKE_ONE_COMPONENT(signed long long, longlong1);
98-
-DECLOP_MAKE_TWO_COMPONENT(signed long long, longlong2);
99-
-DECLOP_MAKE_THREE_COMPONENT(signed long long, longlong3);
100-
-DECLOP_MAKE_FOUR_COMPONENT(signed long long, longlong4);
101-
+DECLOP_MAKE_ONE_COMPONENT(unsigned char, uchar1)
102-
+DECLOP_MAKE_TWO_COMPONENT(unsigned char, uchar2)
103-
+DECLOP_MAKE_THREE_COMPONENT(unsigned char, uchar3)
104-
+DECLOP_MAKE_FOUR_COMPONENT(unsigned char, uchar4)
105-
+
106-
+DECLOP_MAKE_ONE_COMPONENT(signed char, char1)
107-
+DECLOP_MAKE_TWO_COMPONENT(signed char, char2)
108-
+DECLOP_MAKE_THREE_COMPONENT(signed char, char3)
109-
+DECLOP_MAKE_FOUR_COMPONENT(signed char, char4)
110-
+
111-
+DECLOP_MAKE_ONE_COMPONENT(unsigned short, ushort1)
112-
+DECLOP_MAKE_TWO_COMPONENT(unsigned short, ushort2)
113-
+DECLOP_MAKE_THREE_COMPONENT(unsigned short, ushort3)
114-
+DECLOP_MAKE_FOUR_COMPONENT(unsigned short, ushort4)
115-
+
116-
+DECLOP_MAKE_ONE_COMPONENT(signed short, short1)
117-
+DECLOP_MAKE_TWO_COMPONENT(signed short, short2)
118-
+DECLOP_MAKE_THREE_COMPONENT(signed short, short3)
119-
+DECLOP_MAKE_FOUR_COMPONENT(signed short, short4)
120-
+
121-
+DECLOP_MAKE_ONE_COMPONENT(unsigned int, uint1)
122-
+DECLOP_MAKE_TWO_COMPONENT(unsigned int, uint2)
123-
+DECLOP_MAKE_THREE_COMPONENT(unsigned int, uint3)
124-
+DECLOP_MAKE_FOUR_COMPONENT(unsigned int, uint4)
125-
+
126-
+DECLOP_MAKE_ONE_COMPONENT(signed int, int1)
127-
+DECLOP_MAKE_TWO_COMPONENT(signed int, int2)
128-
+DECLOP_MAKE_THREE_COMPONENT(signed int, int3)
129-
+DECLOP_MAKE_FOUR_COMPONENT(signed int, int4)
130-
+
131-
+DECLOP_MAKE_ONE_COMPONENT(float, float1)
132-
+DECLOP_MAKE_TWO_COMPONENT(float, float2)
133-
+DECLOP_MAKE_THREE_COMPONENT(float, float3)
134-
+DECLOP_MAKE_FOUR_COMPONENT(float, float4)
135-
+
136-
+DECLOP_MAKE_ONE_COMPONENT(double, double1)
137-
+DECLOP_MAKE_TWO_COMPONENT(double, double2)
138-
+DECLOP_MAKE_THREE_COMPONENT(double, double3)
139-
+DECLOP_MAKE_FOUR_COMPONENT(double, double4)
140-
+
141-
+DECLOP_MAKE_ONE_COMPONENT(unsigned long, ulong1)
142-
+DECLOP_MAKE_TWO_COMPONENT(unsigned long, ulong2)
143-
+DECLOP_MAKE_THREE_COMPONENT(unsigned long, ulong3)
144-
+DECLOP_MAKE_FOUR_COMPONENT(unsigned long, ulong4)
145-
+
146-
+DECLOP_MAKE_ONE_COMPONENT(signed long, long1)
147-
+DECLOP_MAKE_TWO_COMPONENT(signed long, long2)
148-
+DECLOP_MAKE_THREE_COMPONENT(signed long, long3)
149-
+DECLOP_MAKE_FOUR_COMPONENT(signed long, long4)
150-
+
151-
+DECLOP_MAKE_ONE_COMPONENT(unsigned long long, ulonglong1)
152-
+DECLOP_MAKE_TWO_COMPONENT(unsigned long long, ulonglong2)
153-
+DECLOP_MAKE_THREE_COMPONENT(unsigned long long, ulonglong3)
154-
+DECLOP_MAKE_FOUR_COMPONENT(unsigned long long, ulonglong4)
155-
+
156-
+DECLOP_MAKE_ONE_COMPONENT(signed long long, longlong1)
157-
+DECLOP_MAKE_TWO_COMPONENT(signed long long, longlong2)
158-
+DECLOP_MAKE_THREE_COMPONENT(signed long long, longlong3)
159-
+DECLOP_MAKE_FOUR_COMPONENT(signed long long, longlong4)
160-
161-
#endif
1621
diff -u4 -r --new-file include/hip/hip_ext.h modified_include/hip/hip_ext.h
1632
--- include/hip/hip_ext.h 2026-03-27 20:57:07.000000000 +0000
164-
+++ modified_include/hip/hip_ext.h 2026-03-30 22:25:53.000000000 +0000
3+
+++ modified_include/hip/hip_ext.h 2026-03-31 22:37:08.000000000 +0000
1654
@@ -21,9 +21,11 @@
1665
*/
1676

@@ -204,7 +43,7 @@ diff -u4 -r --new-file include/hip/hip_ext.h modified_include/hip/hip_ext.h
20443

20544
diff -u4 -r --new-file include/hip/hip_runtime_api.h modified_include/hip/hip_runtime_api.h
20645
--- include/hip/hip_runtime_api.h 2026-03-27 20:57:07.000000000 +0000
207-
+++ modified_include/hip/hip_runtime_api.h 2026-03-30 22:25:53.000000000 +0000
46+
+++ modified_include/hip/hip_runtime_api.h 2026-03-31 22:37:08.000000000 +0000
20847
@@ -29,9 +29,8 @@
20948

21049
#ifndef HIP_INCLUDE_HIP_HIP_RUNTIME_API_H
@@ -215,76 +54,7 @@ diff -u4 -r --new-file include/hip/hip_runtime_api.h modified_include/hip/hip_ru
21554
#include <hip/hip_version.h>
21655
#include <hip/hip_common.h>
21756

218-
@@ -41,37 +40,39 @@
219-
HIP_ERROR_NOT_INITIALIZED,
220-
HIP_ERROR_LAUNCH_OUT_OF_RESOURCES
221-
};
222-
223-
-typedef struct {
224-
- // 32-bit Atomics
225-
- unsigned hasGlobalInt32Atomics : 1; ///< 32-bit integer atomics for global memory.
226-
- unsigned hasGlobalFloatAtomicExch : 1; ///< 32-bit float atomic exch for global memory.
227-
- unsigned hasSharedInt32Atomics : 1; ///< 32-bit integer atomics for shared memory.
228-
- unsigned hasSharedFloatAtomicExch : 1; ///< 32-bit float atomic exch for shared memory.
229-
- unsigned hasFloatAtomicAdd : 1; ///< 32-bit float atomic add in global and shared memory.
230-
-
231-
- // 64-bit Atomics
232-
- unsigned hasGlobalInt64Atomics : 1; ///< 64-bit integer atomics for global memory.
233-
- unsigned hasSharedInt64Atomics : 1; ///< 64-bit integer atomics for shared memory.
234-
-
235-
- // Doubles
236-
- unsigned hasDoubles : 1; ///< Double-precision floating point.
237-
-
238-
- // Warp cross-lane operations
239-
- unsigned hasWarpVote : 1; ///< Warp vote instructions (__any, __all).
240-
- unsigned hasWarpBallot : 1; ///< Warp ballot instructions (__ballot).
241-
- unsigned hasWarpShuffle : 1; ///< Warp shuffle operations. (__shfl_*).
242-
- unsigned hasFunnelShift : 1; ///< Funnel two words into one with shift&mask caps.
243-
-
244-
- // Sync
245-
- unsigned hasThreadFenceSystem : 1; ///< __threadfence_system.
246-
- unsigned hasSyncThreadsExt : 1; ///< __syncthreads_count, syncthreads_and, syncthreads_or.
247-
-
248-
- // Misc
249-
- unsigned hasSurfaceFuncs : 1; ///< Surface functions.
250-
- unsigned has3dGrid : 1; ///< Grid and group dims are 3D (rather than 2D).
251-
- unsigned hasDynamicParallelism : 1; ///< Dynamic parallelism.
252-
+typedef struct hipDeviceArch_t {
253-
+// Bitfields are not portable
254-
+ unsigned flags;
255-
+// // 32-bit Atomics
256-
+// unsigned hasGlobalInt32Atomics : 1; ///< 32-bit integer atomics for global memory.
257-
+// unsigned hasGlobalFloatAtomicExch : 1; ///< 32-bit float atomic exch for global memory.
258-
+// unsigned hasSharedInt32Atomics : 1; ///< 32-bit integer atomics for shared memory.
259-
+// unsigned hasSharedFloatAtomicExch : 1; ///< 32-bit float atomic exch for shared memory.
260-
+// unsigned hasFloatAtomicAdd : 1; ///< 32-bit float atomic add in global and shared memory.
261-
+//
262-
+// // 64-bit Atomics
263-
+// unsigned hasGlobalInt64Atomics : 1; ///< 64-bit integer atomics for global memory.
264-
+// unsigned hasSharedInt64Atomics : 1; ///< 64-bit integer atomics for shared memory.
265-
+//
266-
+// // Doubles
267-
+// unsigned hasDoubles : 1; ///< Double-precision floating point.
268-
+//
269-
+// // Warp cross-lane operations
270-
+// unsigned hasWarpVote : 1; ///< Warp vote instructions (__any, __all).
271-
+// unsigned hasWarpBallot : 1; ///< Warp ballot instructions (__ballot).
272-
+// unsigned hasWarpShuffle : 1; ///< Warp shuffle operations. (__shfl_*).
273-
+// unsigned hasFunnelShift : 1; ///< Funnel two words into one with shift&mask caps.
274-
+//
275-
+// // Sync
276-
+// unsigned hasThreadFenceSystem : 1; ///< __threadfence_system.
277-
+// unsigned hasSyncThreadsExt : 1; ///< __syncthreads_count, syncthreads_and, syncthreads_or.
278-
+//
279-
+// // Misc
280-
+// unsigned hasSurfaceFuncs : 1; ///< Surface functions.
281-
+// unsigned has3dGrid : 1; ///< Grid and group dims are 3D (rather than 2D).
282-
+// unsigned hasDynamicParallelism : 1; ///< Dynamic parallelism.
283-
} hipDeviceArch_t;
284-
285-
typedef struct hipUUID_t {
286-
char bytes[16];
287-
@@ -520,9 +521,11 @@
57+
@@ -520,9 +519,11 @@
28858
hipDevP2PAttrHipArrayAccessSupported
28959
} hipDeviceP2PAttr;
29060
typedef struct ihipStream_t* hipStream_t;
@@ -298,7 +68,7 @@ diff -u4 -r --new-file include/hip/hip_runtime_api.h modified_include/hip/hip_ru
29868
typedef struct hipIpcEventHandle_st {
29969
diff -u4 -r --new-file include/hip/hip_runtime_load_api.h modified_include/hip/hip_runtime_load_api.h
30070
--- include/hip/hip_runtime_load_api.h 1970-01-01 00:00:00.000000000 +0000
301-
+++ modified_include/hip/hip_runtime_load_api.h 2026-03-30 22:25:53.000000000 +0000
71+
+++ modified_include/hip/hip_runtime_load_api.h 2026-03-31 22:37:08.000000000 +0000
30272
@@ -0,0 +1,95 @@
30373
+#ifndef HIP_RUNTIME_LOAD_API_
30474
+#define HIP_RUNTIME_LOAD_API_
@@ -395,35 +165,3 @@ diff -u4 -r --new-file include/hip/hip_runtime_load_api.h modified_include/hip/h
395165
+#endif /* __cplusplus */
396166
+
397167
+#endif
398-
diff -u4 -r --new-file include/hip/texture_types.h modified_include/hip/texture_types.h
399-
--- include/hip/texture_types.h 2026-03-27 20:57:07.000000000 +0000
400-
+++ modified_include/hip/texture_types.h 2026-03-30 22:25:53.000000000 +0000
401-
@@ -64,24 +64,24 @@
402-
403-
/**
404-
* hip texture address modes
405-
*/
406-
-enum hipTextureAddressMode {
407-
+typedef enum hipTextureAddressMode {
408-
hipAddressModeWrap = 0,
409-
hipAddressModeClamp = 1,
410-
hipAddressModeMirror = 2,
411-
hipAddressModeBorder = 3
412-
-};
413-
+} hipTextureAddressMode;
414-
415-
/**
416-
* hip texture filter modes
417-
*/
418-
-enum hipTextureFilterMode { hipFilterModePoint = 0, hipFilterModeLinear = 1 };
419-
+typedef enum hipTextureFilterMode { hipFilterModePoint = 0, hipFilterModeLinear = 1 } hipTextureFilterMode;
420-
421-
/**
422-
* hip texture read modes
423-
*/
424-
-enum hipTextureReadMode { hipReadModeElementType = 0, hipReadModeNormalizedFloat = 1 };
425-
+typedef enum hipTextureReadMode { hipReadModeElementType = 0, hipReadModeNormalizedFloat = 1 } hipTextureReadMode;
426-
427-
/**
428-
* hip texture reference
429-
*/

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ AM_CONDITIONAL([FOUND_MPI], [test "x$enable_sync_daemon_mpi" != "xno"])
8181
AC_CHECK_PROG(H2YAML, [h2yaml], [h2yaml], [no])
8282
test "x$H2YAML" = "xno" && AC_MSG_ERROR([Required program 'h2yaml' not found.])
8383

84-
H2YAML_MIN_VERSION=0.4.2
84+
H2YAML_MIN_VERSION=0.4.3
8585
AC_MSG_CHECKING([for h2yaml >= $H2YAML_MIN_VERSION])
8686
H2YAML_VERSION=`$H2YAML --version | cut -d' ' -f2`
8787
AX_COMPARE_VERSION([$H2YAML_VERSION], [ge], [$H2YAML_MIN_VERSION],

0 commit comments

Comments
 (0)