glthread: compile marshal_generated.c faster by breaking it up into 8 files

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4270>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4270>
This commit is contained in:
Marek Olšák
2020-03-05 18:08:58 -05:00
parent cadddbd269
commit 8a3e2cd9b2
6 changed files with 93 additions and 25 deletions
+21 -5
View File
@@ -46,6 +46,8 @@ static inline int safe_mul(int a, int b)
"""
file_index = 0
file_count = 1
current_indent = 0
@@ -324,18 +326,27 @@ class PrintCode(gl_XML.gl_print_base):
out('')
def printBody(self, api):
async_funcs = []
# The first file only contains the dispatch tables
if file_index == 0:
self.print_unmarshal_dispatch_cmd(api)
self.print_create_marshal_table(api)
return
# The remaining files contain the marshal and unmarshal functions
func_per_file = (len(api.functionIterateAll()) // (file_count - 1)) + 1
i = -1
for func in api.functionIterateAll():
i += 1
if i // func_per_file != (file_index - 1):
continue
flavor = func.marshal_flavor()
if flavor in ('skip', 'custom'):
continue
elif flavor == 'async':
self.print_async_body(func)
async_funcs.append(func)
elif flavor == 'sync':
self.print_sync_body(func)
self.print_unmarshal_dispatch_cmd(api)
self.print_create_marshal_table(api)
def show_usage():
@@ -347,14 +358,19 @@ if __name__ == '__main__':
file_name = 'gl_API.xml'
try:
(args, trail) = getopt.getopt(sys.argv[1:], 'm:f:')
(args, trail) = getopt.getopt(sys.argv[1:], 'm:f:i:n:')
except Exception:
show_usage()
for (arg,val) in args:
if arg == '-f':
file_name = val
elif arg == '-i':
file_index = int(val)
elif arg == '-n':
file_count = int(val)
assert file_index < file_count
printer = PrintCode()
api = gl_XML.parse_GL_API(file_name, marshal_XML.marshal_item_factory())
+11 -8
View File
@@ -222,14 +222,17 @@ main_api_exec_c = custom_target(
capture : true,
)
main_marshal_generated_c = custom_target(
'marshal_generated.c',
input : ['gl_marshal.py', 'gl_and_es_API.xml'],
output : 'marshal_generated.c',
command : [prog_python, '@INPUT0@', '-f', '@INPUT1@'],
depend_files : files('marshal_XML.py') + glapi_gen_depends,
capture : true,
)
main_marshal_generated_c = []
foreach x : ['0', '1', '2', '3', '4', '5', '6', '7']
main_marshal_generated_c += custom_target(
'marshal_generated' + x + '.c',
input : ['gl_marshal.py', 'gl_and_es_API.xml'],
output : 'marshal_generated' + x + '.c',
command : [prog_python, '@INPUT0@', '-f', '@INPUT1@', '-i', x, '-n', '8'],
depend_files : files('marshal_XML.py') + glapi_gen_depends,
capture : true,
)
endforeach
glx_generated = []