Debian Codegraph @

media_driver/agnostic/gen11_icllp/vp/kernel_free/media_srcs.cmake

raw
1 # Copyright (c) 2017-2022, Intel Corporation
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the "Software"),
5 # to deal in the Software without restriction, including without limitation
6 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 # and/or sell copies of the Software, and to permit persons to whom the
8 # Software is furnished to do so, subject to the following conditions:
9 #
10 # The above copyright notice and this permission notice shall be included
11 # in all copies or substantial portions of the Software.
12 #
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
17 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19 # OTHER DEALINGS IN THE SOFTWARE.
20
21 # iga64 -i <src> -o <dst> -p <genx> -a
22
23 # Function generate kernel for the specified platform. It assumes
24 # that kernel sources are located in a certain location (see ${krn_dir})
25 # calculated in a function body. And it assumes that output files should
26 # be stored in a certain locations (see ${krn_dir}/${krn}.h/c and ${common_header}).
27 # Notes:
28 # - <platform> = gen<X>_<kind>, for example, gen11_icllp
29 # - As of now this function works for the single platform only (gen11_icllp) while it
30 # actully should process all the platforms at once. This single processing
31 # is needed to generate shared ${common_header} with the unified kernels definition.
32 function(gen_kernel_from_asm)
33
34 set(platform "gen11_icllp")
35 set(name "vp")
36 set(genx "g11")
37 set(kind "icllp")
38
39 set(krn_dir ${CMAKE_SOURCE_DIR}/media_driver/agnostic/${platform}/vp/kernel_free)
40 set(link_file ${krn_dir}/component_release/LinkFile.txt)
41 set(krn ig${name}krn_${genx}_${kind})
42 set(header ${CMAKE_CURRENT_LIST_DIR}/${name}krnheader.h)
43 set(common_header ${CMAKE_SOURCE_DIR}/media_common/agnostic/common/vp/kernel/${name}krnheader.h)
44 set(cache_dir ${CMAKE_SOURCE_DIR}/media_driver/agnostic/${platform}/vp/kernel_free/cache_kernel)
45 set(cache_hex_dir ${cache_dir}/hex)
46
47 message("krn: " ${krn})
48 message("krn_dir: " ${krn_dir})
49 message("cache_dir: " ${cache_dir})
50 message("link_file: " ${link_file})
51 message("header: " ${header})
52 message("common_header: " ${common_header})
53
54 add_custom_command(
55 OUTPUT ${cache_dir} ${cache_hex_dir}
56 COMMAND ${CMAKE_COMMAND} -E make_directory ${cache_dir}
57 COMMAND ${CMAKE_COMMAND} -E make_directory ${cache_hex_dir}
58 COMMENT "Creating VP cmfc kernels output directory")
59
60 # Compiling all the sources in the kernel source directory
61 file(GLOB srcs ${krn_dir}/Source/*.asm)
62 set(hexs "")
63 foreach(src ${srcs})
64
65 get_filename_component(obj ${src} NAME_WE)
66 add_custom_command(
67 OUTPUT ${obj}.hex
68 DEPENDS KrnToHex_IGA ${src} ${cache_dir} ${cache_hex_dir}
69 WORKING_DIRECTORY ${cache_hex_dir}
70 COMMAND ${IGA} ${src} -p=11 -o ${obj}.krn
71 COMMAND KrnToHex_IGA ${obj}.krn
72 COMMAND ${CMAKE_COMMAND} -E remove ${obj}.krn
73 COMMENT "Compiling ${src} ...\
74 ${obj}.krn generated..."
75 )
76
77 list(APPEND hexs ${obj}.hex)
78
79 endforeach()
80
81 # Generating common .bin file containing all the kernels and its header
82 # file shared across all platforms (${name}krnheader.h)
83 add_custom_command(
84 OUTPUT ${krn}.bin ${common_header}
85 DEPENDS GenKrnBin ${hexs} ${link_file}
86 COMMAND ${CMAKE_COMMAND} -E copy ${link_file} ${cache_hex_dir}
87 COMMAND GenKrnBin ${cache_hex_dir} ${name} ${genx} icllp
88 COMMAND ${CMAKE_COMMAND} -E copy ${cache_hex_dir}/${krn}.h ${header}
89 #COMMAND ${CMAKE_COMMAND} -E copy ${header} ${common_header}
90 COMMENT "Copying link file ${link_file} to folder ${cache_hex_dir}...\
91 Generating bin files from hexes in ${cache_hex_dir}...\
92 Copying header file ${krn}.h to ${common_header}..."
93 )
94
95 # Generating kernel from the .bin file
96 message("Kernel file ${krn_dir}/${krn}.c will be generated")
97 add_custom_command(
98 OUTPUT ${krn_dir}/${krn}.c ${krn_dir}/${krn}.h
99 DEPENDS KernelBinToSource ${krn}.bin ${common_header}
100 WORKING_DIRECTORY ${cache_hex_dir}
101 COMMAND KernelBinToSource -i ${krn}.bin -o ${krn_dir})
102 endfunction()
103
104 if(BUILD_KERNELS)
105 gen_kernel_from_asm()
106 endif()
107
108 set(TMP_SOURCES_
109 ${CMAKE_CURRENT_LIST_DIR}/igvpkrn_g11_icllp.c
110 )
111
112 set(TMP_HEADERS_
113 ${CMAKE_CURRENT_LIST_DIR}/igvpkrn_g11_icllp.h
114 )
115
116
117 set(VP_SOURCES_
118 ${VP_SOURCES_}
119 ${TMP_SOURCES_}
120 )
121
122 set(VP_HEADERS_
123 ${VP_HEADERS_}
124 ${TMP_HEADERS_}
125 )
126
127 source_group( "Kernel\\VpKernel" FILES ${TMP_SOURCES_} ${TMP_HEADERS_} )
128 set(TMP_SOURCES_ "")
129 set(TMP_HEADERS_ "")
130
131 set(VP_PRIVATE_INCLUDE_DIRS_
132 ${VP_PRIVATE_INCLUDE_DIRS_}
133 ${CMAKE_CURRENT_LIST_DIR}
134 )