diff options
author | David Gross <dgross@google.com> | 2015-03-31 13:56:05 -0700 |
---|---|---|
committer | David Gross <dgross@google.com> | 2015-04-02 14:20:11 -0700 |
commit | fb78d4c6604bd243578ce8071e31f68c023d82cf (patch) | |
tree | e9498134afe037468fe89bf2f830e495aee14c7b | |
parent | 2133b9d55fa99617126c7ddb31df0f821a1156ff (diff) | |
download | android_frameworks_compile_slang-fb78d4c6604bd243578ce8071e31f68c023d82cf.tar.gz android_frameworks_compile_slang-fb78d4c6604bd243578ce8071e31f68c023d82cf.tar.bz2 android_frameworks_compile_slang-fb78d4c6604bd243578ce8071e31f68c023d82cf.zip |
Support new-style kernels with no output and no input.
Such kernels get the definition of their iteration space solely through LaunchOptions.
No runtime testing of no-allocation kernels yet.
Bug 19950069
Change-Id: I452f948967d52e0ce8998628d554ab188cae9116
-rw-r--r-- | slang_rs_export_foreach.cpp | 8 | ||||
-rw-r--r-- | slang_rs_reflection.cpp | 49 | ||||
-rw-r--r-- | tests/F_kernel_badsig/kernel_badsig.rs | 1 | ||||
-rw-r--r-- | tests/F_kernel_badsig/stderr.txt.expect | 2 | ||||
-rw-r--r-- | tests/P_kernel_noalloc/kernel_noalloc.rs | 6 | ||||
-rw-r--r-- | tests/P_kernel_noalloc/stderr.txt.expect | 0 | ||||
-rw-r--r-- | tests/P_kernel_noalloc/stdout.txt.expect | 0 | ||||
-rw-r--r-- | tests/P_kernel_noalloc_noarg/kernel_noalloc_noarg.rs | 6 | ||||
-rw-r--r-- | tests/P_kernel_noalloc_noarg/stderr.txt.expect | 0 | ||||
-rw-r--r-- | tests/P_kernel_noalloc_noarg/stdout.txt.expect | 0 |
10 files changed, 46 insertions, 26 deletions
diff --git a/slang_rs_export_foreach.cpp b/slang_rs_export_foreach.cpp index d3ba154..026e6fc 100644 --- a/slang_rs_export_foreach.cpp +++ b/slang_rs_export_foreach.cpp @@ -276,12 +276,14 @@ bool RSExportForEach::validateAndConstructKernelParams( } // Check that we have at least one allocation to use for dimensions. - if (valid && mIns.empty() && !mHasReturnType) { + if (valid && mIns.empty() && !mHasReturnType && Context->getTargetAPI() < SLANG_23_TARGET_API) { Context->ReportError(FD->getLocation(), - "Compute kernel %0() must have at least one " + "Compute kernel %0() targeting SDK levels " + "%1-%2 must have at least one " "input parameter or a non-void return " "type") - << FD->getName(); + << FD->getName() << SLANG_MINIMUM_TARGET_API + << (SLANG_23_TARGET_API - 1); valid = false; } diff --git a/slang_rs_reflection.cpp b/slang_rs_reflection.cpp index dfa6e75..f1d9d3d 100644 --- a/slang_rs_reflection.cpp +++ b/slang_rs_reflection.cpp @@ -692,17 +692,18 @@ void RSReflectionJava::genExportForEach(const RSExportForEach *EF) { // forEach_*() ArgTy Args; - - slangAssert(EF->getNumParameters() > 0 || EF->hasReturn()); + bool HasAllocation = false; // at least one in/out allocation? const RSExportForEach::InVec &Ins = EF->getIns(); const RSExportForEach::InTypeVec &InTypes = EF->getInTypes(); const RSExportType *OET = EF->getOutType(); if (Ins.size() == 1) { + HasAllocation = true; Args.push_back(std::make_pair("Allocation", "ain")); } else if (Ins.size() > 1) { + HasAllocation = true; for (RSExportForEach::InIter BI = Ins.begin(), EI = Ins.end(); BI != EI; BI++) { @@ -711,8 +712,10 @@ void RSReflectionJava::genExportForEach(const RSExportForEach *EF) { } } - if (EF->hasOut() || EF->hasReturn()) + if (EF->hasOut() || EF->hasReturn()) { + HasAllocation = true; Args.push_back(std::make_pair("Allocation", "aout")); + } const RSExportRecordType *ERT = EF->getParamPacketType(); if (ERT) { @@ -737,34 +740,36 @@ void RSReflectionJava::genExportForEach(const RSExportForEach *EF) { } if (mRSContext->getTargetAPI() >= SLANG_JB_MR2_TARGET_API) { - startFunction(AM_Public, false, "void", "forEach_" + EF->getName(), Args); + if (HasAllocation) { + startFunction(AM_Public, false, "void", "forEach_" + EF->getName(), Args); - mOut.indent() << "forEach_" << EF->getName(); - mOut << "("; + mOut.indent() << "forEach_" << EF->getName(); + mOut << "("; - if (Ins.size() == 1) { - mOut << "ain, "; + if (Ins.size() == 1) { + mOut << "ain, "; - } else if (Ins.size() > 1) { - for (RSExportForEach::InIter BI = Ins.begin(), EI = Ins.end(); BI != EI; - BI++) { + } else if (Ins.size() > 1) { + for (RSExportForEach::InIter BI = Ins.begin(), EI = Ins.end(); BI != EI; + BI++) { - mOut << "ain_" << (*BI)->getName().str() << ", "; + mOut << "ain_" << (*BI)->getName().str() << ", "; + } } - } - if (EF->hasOut() || EF->hasReturn()) { - mOut << "aout, "; - } + if (EF->hasOut() || EF->hasReturn()) { + mOut << "aout, "; + } - if (EF->hasUsrData()) { - mOut << Args.back().second << ", "; - } + if (EF->hasUsrData()) { + mOut << Args.back().second << ", "; + } - // No clipped bounds to pass in. - mOut << "null);\n"; + // No clipped bounds to pass in. + mOut << "null);\n"; - endFunction(); + endFunction(); + } // Add the clipped kernel parameters to the Args list. Args.push_back(std::make_pair("Script.LaunchOptions", "sc")); diff --git a/tests/F_kernel_badsig/kernel_badsig.rs b/tests/F_kernel_badsig/kernel_badsig.rs index ab64847..394e9c9 100644 --- a/tests/F_kernel_badsig/kernel_badsig.rs +++ b/tests/F_kernel_badsig/kernel_badsig.rs @@ -1,3 +1,4 @@ +// -target-api 22 #pragma version(1) #pragma rs java_package_name(foo) diff --git a/tests/F_kernel_badsig/stderr.txt.expect b/tests/F_kernel_badsig/stderr.txt.expect index 633158c..ca771ad 100644 --- a/tests/F_kernel_badsig/stderr.txt.expect +++ b/tests/F_kernel_badsig/stderr.txt.expect @@ -1 +1 @@ -kernel_badsig.rs:4:16: error: Compute kernel root() must have at least one input parameter or a non-void return type +kernel_badsig.rs:5:16: error: Compute kernel root() targeting SDK levels 11-22 must have at least one input parameter or a non-void return type diff --git a/tests/P_kernel_noalloc/kernel_noalloc.rs b/tests/P_kernel_noalloc/kernel_noalloc.rs new file mode 100644 index 0000000..ab64847 --- /dev/null +++ b/tests/P_kernel_noalloc/kernel_noalloc.rs @@ -0,0 +1,6 @@ +#pragma version(1) +#pragma rs java_package_name(foo) + +void RS_KERNEL root(uint32_t x) { +} + diff --git a/tests/P_kernel_noalloc/stderr.txt.expect b/tests/P_kernel_noalloc/stderr.txt.expect new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/P_kernel_noalloc/stderr.txt.expect diff --git a/tests/P_kernel_noalloc/stdout.txt.expect b/tests/P_kernel_noalloc/stdout.txt.expect new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/P_kernel_noalloc/stdout.txt.expect diff --git a/tests/P_kernel_noalloc_noarg/kernel_noalloc_noarg.rs b/tests/P_kernel_noalloc_noarg/kernel_noalloc_noarg.rs new file mode 100644 index 0000000..e1ccb09 --- /dev/null +++ b/tests/P_kernel_noalloc_noarg/kernel_noalloc_noarg.rs @@ -0,0 +1,6 @@ +#pragma version(1) +#pragma rs java_package_name(foo) + +void RS_KERNEL root() { +} + diff --git a/tests/P_kernel_noalloc_noarg/stderr.txt.expect b/tests/P_kernel_noalloc_noarg/stderr.txt.expect new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/P_kernel_noalloc_noarg/stderr.txt.expect diff --git a/tests/P_kernel_noalloc_noarg/stdout.txt.expect b/tests/P_kernel_noalloc_noarg/stdout.txt.expect new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/P_kernel_noalloc_noarg/stdout.txt.expect |