1+ message (STATUS "Building host math functions" )
2+ set (ROCm-Device-Libs_SRC_DIR ${CMAKE_SOURCE_DIR} /bitcode/ROCm-Device-Libs)
3+ set (OCML_SRC_DIR ${ROCm-Device-Libs_SRC_DIR}/ocml/src)
4+ set (OCML_INCLUDE_DIR ${ROCm-Device-Libs_SRC_DIR}/ocml/include)
5+ set (OCML_LIB_DIR ${ROCm-Device-Libs_SRC_DIR}/ocml/lib)
6+
7+ # Add include directories for OCML
8+ include_directories (
9+ ${OCML_INCLUDE_DIR}
10+ ${ROCm-Device-Libs_SRC_DIR}/irif/inc
11+ ${ROCm-Device-Libs_SRC_DIR}/oclc/inc
12+ ${ROCm-Device-Libs_SRC_DIR}/ocml/inc
13+ ${CMAKE_CURRENT_SOURCE_DIR}
14+ )
15+
16+
17+ # Create host_math_funcs directory in build
18+ file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR} /host_math_funcs )
19+
20+ # Copy ncdfF.cl to the build directory
21+
22+ # cospi OpenCL in chipStar (extern)
23+ # cospif OpenCL in chipStar (calling cospi)
24+ file (COPY ${OCML_SRC_DIR} /trigredF.h DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
25+ file (COPY ${OCML_SRC_DIR} /sincospiredF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
26+ file (COPY ${OCML_SRC_DIR} /tanpiredF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
27+ file (COPY ${OCML_SRC_DIR} /trigpiredF.h DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
28+ file (COPY ${OCML_SRC_DIR} /trigpiredF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
29+ file (COPY ${OCML_SRC_DIR} /cospiF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
30+
31+ file (COPY ${OCML_SRC_DIR} /trigpiredD.h DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
32+ file (COPY ${OCML_SRC_DIR} /sincospiredD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
33+ file (COPY ${OCML_SRC_DIR} /tanpiredD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
34+ file (COPY ${OCML_SRC_DIR} /trigpiredD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
35+ file (COPY ${OCML_SRC_DIR} /cospiD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
36+
37+ file (COPY ${OCML_SRC_DIR} /erfcD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
38+ file (COPY ${OCML_SRC_DIR} /erfcF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
39+
40+ file (COPY ${OCML_SRC_DIR} /expD_base.h DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
41+ file (COPY ${OCML_SRC_DIR} /expF_base.h DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
42+ file (COPY ${OCML_SRC_DIR} /logD_base.h DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
43+ file (COPY ${OCML_SRC_DIR} /logF_base.h DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
44+ file (COPY ${OCML_SRC_DIR} /logD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
45+ file (COPY ${OCML_SRC_DIR} /logF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
46+
47+
48+ file (COPY ${OCML_SRC_DIR} /expD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
49+ file (COPY ${OCML_SRC_DIR} /expF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
50+
51+ # erfcinv OCML in chipStar (__ocml_erfcinv_f64)
52+ file (COPY ${OCML_SRC_DIR} /erfcinvD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
53+
54+ # # erfcinvf OCML in chipStar (__ocml_erfcinv_f32)
55+ file (COPY ${OCML_SRC_DIR} /erfcinvF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
56+
57+ # # erfcx OCML in chipStar (__ocml_erfcx_f64)
58+ file (COPY ${OCML_SRC_DIR} /erfcxD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
59+
60+ # # erfcxf OCML in chipStar (__ocml_erfcx_f32)
61+ file (COPY ${OCML_SRC_DIR} /erfcxF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
62+
63+ # # erfinv OCML in chipStar (__ocml_erfinv_f64)
64+ file (COPY ${OCML_SRC_DIR} /erfinvD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
65+
66+ # # erfinvf OCML in chipStar (__ocml_erfinv_f32)
67+ file (COPY ${OCML_SRC_DIR} /erfinvF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
68+
69+ # # normcdf OCML in chipStar (__ocml_ncdf_f64)
70+ file (COPY ${OCML_SRC_DIR} /ncdfD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
71+
72+ # # normcdff OCML in chipStar (__ocml_ncdf_f32)
73+ file (COPY ${OCML_SRC_DIR} /ncdfF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
74+
75+ # # normcdfinv OCML in chipStar (__ocml_ncdfinv_f64)
76+ file (COPY ${OCML_SRC_DIR} /ncdfinvD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
77+
78+ # # normcdfinvf OCML in chipStar (__ocml_ncdfinv_f32)
79+ file (COPY ${OCML_SRC_DIR} /ncdfinvF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
80+
81+ # # rcbrt OCML in chipStar (__ocml_rcbrt_f64)
82+ file (COPY ${OCML_SRC_DIR} /rcbrtD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
83+
84+ # # rcbrtf OCML in chipStar (__ocml_rcbrt_f32)
85+ file (COPY ${OCML_SRC_DIR} /rcbrtF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
86+
87+ # # sincospi OCML in chipStar (__ocml_sincospi_f64)
88+ file (COPY ${OCML_SRC_DIR} /sincospiD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
89+
90+ # # sincospif OCML in chipStar (__ocml_sincospi_f32)
91+ file (COPY ${OCML_SRC_DIR} /sincospiF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
92+
93+ # # sinpi OpenCL in chipStar (extern)
94+ file (COPY ${OCML_SRC_DIR} /sinpiD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
95+
96+ # # sinpif OpenCL in chipStar (call sinpi)
97+ file (COPY ${OCML_SRC_DIR} /sinpiF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
98+
99+ # rsqrt OCML in chipStar (__ocml_rsqrt_f64)
100+ file (COPY ${OCML_SRC_DIR} /rsqrtD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
101+
102+ # rsqrtf OCML in chipStar (__ocml_rsqrt_f32)
103+ file (COPY ${OCML_SRC_DIR} /rsqrtF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
104+
105+ # llmax calling max() in chipStar
106+ # llmin calling min() in chipStar
107+ # ullmax calling max() in chipStar
108+ # ullmin calling min() in chipStar
109+ # umax calling max() in chipStar
110+ # umin calling min() in chipStar
111+
112+ # signbit OCML in chipStar (__ocml_signbit_f64)
113+ file (COPY ${OCML_SRC_DIR} /signbitD.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
114+ file (COPY ${OCML_SRC_DIR} /signbitF.cl DESTINATION ${CMAKE_BINARY_DIR} /host_math_funcs )
115+
116+
117+ # Gather all .cl sources from the OCML source directory
118+ file (GLOB OCML_CL_SOURCES ${CMAKE_BINARY_DIR} /host_math_funcs/*.cl )
119+
120+ # Print the list of gathered .cl sources for debugging
121+ message (STATUS "OCML CL Sources: ${OCML_CL_SOURCES} " )
122+
123+ # Set the language for the target
124+ set_source_files_properties (${OCML_CL_SOURCES} PROPERTIES LANGUAGE C )
125+
126+ # Add the library target
127+ add_library (ocml_host_math_funcs STATIC ${OCML_CL_SOURCES} )
128+ set_target_properties (ocml_host_math_funcs PROPERTIES
129+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} "
130+ )
131+ # Set the linker language explicitly
132+ set_target_properties (ocml_host_math_funcs PROPERTIES LINKER_LANGUAGE C )
133+
134+ # Add ocml_host_math_funcs to the export set
135+ install (TARGETS ocml_host_math_funcs EXPORT hip-targets )
136+ install (TARGETS ocml_host_math_funcs EXPORT CHIPTargets)
0 commit comments