<div dir="ltr">Type-o in the subject (Suport).<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 3, 2016 at 6:37 PM, Jan Vesely <span dir="ltr"><<a href="mailto:jan.vesely@rutgers.edu" target="_blank">jan.vesely@rutgers.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Reuses parts of Tom's fract test patch.<br>
There is no change in generated tests with single output<br>
<br>
Signed-off-by: Jan Vesely <<a href="mailto:jan.vesely@rutgers.edu">jan.vesely@rutgers.edu</a>><br>
---<br>
generated_tests/genclbuiltins.py | 108 ++++++++++++++++++++++++++++-----------<br>
1 file changed, 79 insertions(+), 29 deletions(-)<br>
<br>
diff --git a/generated_tests/genclbuiltins.py b/generated_tests/genclbuiltins.py<br>
index 24bf249..7df55c9 100644<br>
--- a/generated_tests/genclbuiltins.py<br>
+++ b/generated_tests/genclbuiltins.py<br>
@@ -109,13 +109,24 @@ B = {<br>
<br>
# vecSizes has the layout [in0width, ..., inNwidth] where outType width is<br>
# assumed to match the width of the first input<br>
-def gen_kernel(f, fnName, inTypes, outType, vecSizes, typePrefix):<br>
+def gen_kernel(f, fnName, inTypes, outTypes, vecSizes, typePrefix, outLoc='private'):<br>
f.write('kernel void test_' + typePrefix + str(vecSizes[0]) + '_' + fnName<br>
- + '_' + inTypes[0]+'(global '+outType+'* out')<br>
+ + (('_' + outLoc) if len(outTypes) > 1 else '')<br>
+ + '_' + inTypes[0] + '(global ' + outTypes[0] + '* out')<br>
+ for arg in range(1, len(outTypes)):<br>
+ f.write(', global '+outTypes[arg]+'* out'+str(arg))<br>
for arg in range(0, len(inTypes)):<br>
f.write(', global '+inTypes[arg]+'* in'+str(arg))<br>
f.write('){\n')<br>
<br>
+ for arg in range(1, len(outTypes)):<br>
+ f.write(' ' + outLoc + ' ' + outTypes[arg] + ('' if vecSizes[0] == 1 else str(vecSizes[0])));<br>
+ if (outLoc == 'global'):<br>
+ f.write(' *tmp' + str(arg) + ' = out' + str(arg) + ';\n');<br>
+ else:<br>
+ #FIXME: This assumes WG size of 1<br></blockquote><div><br></div><div>Was this FIXME left here intentionally for whoever needs that feature later? Cause yeah, the generated code for local memory tests with non-1 WG sizes is definitely broken.<br><br></div><div>Do you plan on tackling that, or do you want to punt on it and just assume WG size =1 for now?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ f.write(' tmp' + str(arg) + ';\n');<br>
+<br>
suffix = ';'<br>
if (vecSizes[0] == 1):<br>
f.write(' out[get_global_id(0)] = ')<br>
@@ -134,88 +145,113 @@ def gen_kernel(f, fnName, inTypes, outType, vecSizes, typePrefix):<br>
f.write('in'+str(arg)+'[get_global_id(0)]')<br>
else:<br>
f.write('vload'+str(vecSizes[arg])+'(get_global_id(0), in'+str(arg)+')')<br></blockquote><div><br></div><div>Might be nice to have a blank line here.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ for arg in range(1, len(outTypes)):<br>
+ if (outLoc == 'global'):<br>
+ f.write(', &tmp' + str(arg) + '[get_global_id(0)]')<br>
+ else:<br>
+ f.write(', &tmp' + str(arg))<br>
+<br>
+ f.write(suffix + '\n')<br>
+<br></blockquote><div><br></div><div>And one less here.<br><br></div><div>Let me know about the local WG size thing. Otherwise, this looks ok with the spelling/formatting changes. I'm by no means a python expert, but this looks functional, and I've already re-used it to add frexp tests.<br><br></div><div>--Aaron<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ if (outLoc != 'global'):<br>
+ for arg in range(1, len(outTypes)):<br>
+ if (vecSizes[0] == 1):<br>
+ f.write(' out'+ str(arg) +'[get_global_id(0)] = tmp' + str(arg))<br>
+ else:<br>
+ f.write(' vstore' + str(vecSizes[0]) + '(tmp' + str(arg) + ', get_global_id(0), out' + str(arg) + ')')<br>
+ f.write(';\n')<br>
<br>
- f.write(suffix+'\n}\n\n')<br>
+ f.write('}\n\n')<br>
<br>
<br>
<br>
-def gen_kernel_1_arg(f, fnName, inType, outType):<br>
+def gen_kernel_1_arg(f, fnName, inType, outTypes, loc = 'private'):<br>
for vecSize in ALL_WIDTHS:<br>
- gen_kernel(f, fnName, [inType], outType, [vecSize], '')<br>
+ gen_kernel(f, fnName, [inType], outTypes, [vecSize], '', loc)<br>
<br>
<br>
# 2 argument kernel with input types that match their vector size<br>
-def gen_kernel_2_arg_same_size(f, fnName, inTypes, outType):<br>
+def gen_kernel_2_arg_same_size(f, fnName, inTypes, outTypes):<br>
for vecSize in ALL_WIDTHS:<br>
- gen_kernel(f, fnName, inTypes, outType, [vecSize, vecSize],<br>
+ gen_kernel(f, fnName, inTypes, outTypes, [vecSize, vecSize],<br>
'')<br>
<br>
<br>
# 2 argument kernel with 1 vector and one scalar input argument<br>
-def gen_kernel_2_arg_mixed_size(f, fnName, inTypes, outType):<br>
+def gen_kernel_2_arg_mixed_size(f, fnName, inTypes, outTypes):<br>
for vecSize in VEC_WIDTHS:<br>
- gen_kernel(f, fnName, inTypes, outType, [vecSize, 1], 'tss_')<br>
+ gen_kernel(f, fnName, inTypes, outTypes, [vecSize, 1], 'tss_')<br>
<br>
<br>
# 2 argument kernel with 1 vector and one scalar input argument with multiple<br>
# input data types<br>
-def gen_kernel_2_arg_mixed_sign(f, fnName, inTypes, outType):<br>
+def gen_kernel_2_arg_mixed_sign(f, fnName, inTypes, outTypes):<br>
for vecSize in ALL_WIDTHS:<br>
- gen_kernel(f, fnName, inTypes, outType, [vecSize, vecSize],<br>
+ gen_kernel(f, fnName, inTypes, outTypes, [vecSize, vecSize],<br>
'')<br>
<br>
<br>
# 3-argument built-in functions<br>
<br>
<br>
-def gen_kernel_3_arg_same_type(f, fnName, inTypes, outType):<br>
+def gen_kernel_3_arg_same_type(f, fnName, inTypes, outTypes):<br>
for vecSize in ALL_WIDTHS:<br>
- gen_kernel(f, fnName, inTypes, outType,<br>
+ gen_kernel(f, fnName, inTypes, outTypes,<br>
[vecSize, vecSize, vecSize], ''<br>
)<br>
<br>
-def gen_kernel_3_arg_mixed_size_tss(f, fnName, inTypes, outType):<br>
+def gen_kernel_3_arg_mixed_size_tss(f, fnName, inTypes, outTypes):<br>
for vecSize in VEC_WIDTHS:<br>
- gen_kernel(f, fnName, inTypes, outType,<br>
+ gen_kernel(f, fnName, inTypes, outTypes,<br>
[vecSize, 1, 1], 'tss_')<br>
<br>
-def gen_kernel_3_arg_mixed_size_tts(f, fnName, inTypes, outType):<br>
+def gen_kernel_3_arg_mixed_size_tts(f, fnName, inTypes, outTypes):<br>
for vecSize in VEC_WIDTHS:<br>
- gen_kernel(f, fnName, inTypes, outType,<br>
+ gen_kernel(f, fnName, inTypes, outTypes,<br>
[vecSize, vecSize, 1], 'tts_')<br>
<br>
<br>
def generate_kernels(f, dataType, fnName, fnDef):<br>
+<br>
argTypes = getArgTypes(dataType, fnDef['arg_types'])<br>
<br>
# For len(argTypes), remember that this includes the output arg<br>
if (len(argTypes) == 2):<br>
- gen_kernel_1_arg(f, fnName, argTypes[1], argTypes[0])<br>
+ gen_kernel_1_arg(f, fnName, argTypes[1], [argTypes[0]])<br>
return<br>
<br>
if (len(argTypes) == 3 and not fnName is 'upsample'):<br>
- gen_kernel_2_arg_same_size(f, fnName,<br>
- [argTypes[1], argTypes[2]], argTypes[0])<br>
+ if (getNumOutArgs(fnDef) == 2):<br>
+ gen_kernel_1_arg(f, fnName,<br>
+ argTypes[2], [argTypes[0], argTypes[1]], 'private')<br>
+ gen_kernel_1_arg(f, fnName,<br>
+ argTypes[2], [argTypes[0], argTypes[1]], 'local')<br>
+ gen_kernel_1_arg(f, fnName,<br>
+ argTypes[2], [argTypes[0], argTypes[1]], 'global')<br>
+ else:<br>
+ gen_kernel_2_arg_same_size(f, fnName,<br>
+ [argTypes[1], argTypes[2]], [argTypes[0]])<br>
if (fnDef['function_type'] is 'tss'):<br>
gen_kernel_2_arg_mixed_size(f, fnName,<br>
- [argTypes[1], argTypes[2]], argTypes[0])<br>
+ [argTypes[1], argTypes[2]], [argTypes[0]])<br>
return<br>
<br>
if (len(argTypes) == 4):<br>
gen_kernel_3_arg_same_type(f, fnName,<br>
- [argTypes[1], argTypes[2], argTypes[3]], argTypes[0])<br>
+ [argTypes[1], argTypes[2], argTypes[3]], [argTypes[0]])<br>
if (fnDef['function_type'] is 'tss'):<br>
gen_kernel_3_arg_mixed_size_tss(f, fnName,<br>
- [argTypes[1], argTypes[2], argTypes[3]], argTypes[0])<br>
+ [argTypes[1], argTypes[2], argTypes[3]], [argTypes[0]])<br>
if (fnDef['function_type'] is 'tts'):<br>
gen_kernel_3_arg_mixed_size_tts(f, fnName,<br>
- [argTypes[1], argTypes[2], argTypes[3]], argTypes[0])<br>
+ [argTypes[1], argTypes[2], argTypes[3]], [argTypes[0]])<br>
return<br>
<br>
if (fnName is 'upsample'):<br>
gen_kernel_2_arg_mixed_sign(f, fnName,<br>
[argTypes[1], argTypes[2]],<br>
- argTypes[0])<br>
+ [argTypes[0]])<br>
return<br>
<br>
def getValue(type, val, isVector):<br>
@@ -301,6 +337,15 @@ def getArgTypes(baseType, argTypes):<br>
def isFloatType(t):<br>
return t not in U<br>
<br>
+def getNumOutArgs(functionDef):<br>
+ if 'num_out_args' in functionDef:<br>
+ return functionDef['num_out_args']<br>
+ else:<br>
+ return 1<br>
+<br>
+def isOutArg(functionDef, argIdx):<br>
+ return argIdx < getNumOutArgs(functionDef)<br>
+<br>
# Print a test with all-vector inputs/outputs and/or mixed vector/scalar args<br>
def print_test(f, fnName, argType, functionDef, tests, numTests, vecSize, fntype):<br>
# If the test allows mixed vector/scalar arguments, handle the case with<br>
@@ -332,7 +377,7 @@ def print_test(f, fnName, argType, functionDef, tests, numTests, vecSize, fntype<br>
for arg in range(0, argCount):<br>
argInOut = ''<br>
argVal = getStrVal(argType, tests[arg], (vecSize > 1))<br>
- if arg == 0:<br>
+ if isOutArg(functionDef, arg):<br>
argInOut = 'arg_out: '<br>
else:<br>
argInOut = 'arg_in: '<br>
@@ -345,7 +390,7 @@ def print_test(f, fnName, argType, functionDef, tests, numTests, vecSize, fntype<br>
'[' + str(numTests * vecSize) + '] ' +<br>
''.join(map(lambda x: (x + ' ') * vecSize, argVal.split()))<br>
)<br>
- if arg == 0:<br>
+ if isOutArg(functionDef, arg) :<br>
f.write(' tolerance {0} '.format(tolerance))<br>
# Use ulp tolerance for float types<br>
if isFloatType(argTypes[arg]):<br>
@@ -418,8 +463,13 @@ def gen(types, minVersions, functions, testDefs, dirName):<br>
sizes = sorted(VEC_WIDTHS)<br>
sizes.insert(0, 1) # Add 1-wide scalar to the vector widths<br>
for vecSize in sizes:<br>
- print_test(f, fnName, dataType, functionDef, tests,<br>
- numTests, vecSize, fnType)<br>
+ if (getNumOutArgs(functionDef) == 1):<br>
+ print_test(f, fnName, dataType, functionDef, tests,<br>
+ numTests, vecSize, fnType)<br>
+ else:<br>
+ for loc in ['_private', '_local', '_global']:<br>
+ print_test(f, fnName + loc, dataType, functionDef, tests,<br>
+ numTests, vecSize, fnType)<br>
<br>
# Terminate the header section<br>
f.write('!*/\n\n')<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.0<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div></div>