Add rsForEachInternal
Bug: 23535985
Added a compiler intrinsic rsParallelFor to the runtime API, which
is translated into an internal API (rsForEachInternal) by slang.
Added a test to RsTest (for native) and RSTest_CompatLib
(for support).
Enhanced the auto api generator to handle ellipsis argument,
intrinsics, internal-only APIs, and special level for API under
development.
Change-Id: I6e2cf3db868f426aa8e0b9a77732b66c1e6b9f03
diff --git a/api/Specification.cpp b/api/Specification.cpp
index f02e429..28e5231 100644
--- a/api/Specification.cpp
+++ b/api/Specification.cpp
@@ -32,7 +32,7 @@
using namespace std;
// API level when RenderScript was added.
-const int MIN_API_LEVEL = 9;
+const unsigned int MIN_API_LEVEL = 9;
const NumericalType TYPES[] = {
{"f16", "FLOAT_16", "half", "float", FLOATING_POINT, 11, 5},
@@ -50,6 +50,8 @@
const int NUM_TYPES = sizeof(TYPES) / sizeof(TYPES[0]);
+static const char kTagUnreleased[] = "UNRELEASED";
+
// The singleton of the collected information of all the spec files.
SystemSpecification systemSpecification;
@@ -201,26 +203,34 @@
}
}
-bool VersionInfo::scan(Scanner* scanner, int maxApiLevel) {
+bool VersionInfo::scan(Scanner* scanner, unsigned int maxApiLevel) {
if (scanner->findOptionalTag("version:")) {
const string s = scanner->getValue();
- sscanf(s.c_str(), "%i %i", &minVersion, &maxVersion);
- if (minVersion && minVersion < MIN_API_LEVEL) {
- scanner->error() << "Minimum version must >= 9\n";
- }
- if (minVersion == MIN_API_LEVEL) {
- minVersion = 0;
- }
- if (maxVersion && maxVersion < MIN_API_LEVEL) {
- scanner->error() << "Maximum version must >= 9\n";
+ if (s.compare(0, sizeof(kTagUnreleased), kTagUnreleased) == 0) {
+ // The API is still under development and does not have
+ // an official version number.
+ minVersion = maxVersion = kUnreleasedVersion;
+ } else {
+ sscanf(s.c_str(), "%u %u", &minVersion, &maxVersion);
+ if (minVersion && minVersion < MIN_API_LEVEL) {
+ scanner->error() << "Minimum version must >= 9\n";
+ }
+ if (minVersion == MIN_API_LEVEL) {
+ minVersion = 0;
+ }
+ if (maxVersion && maxVersion < MIN_API_LEVEL) {
+ scanner->error() << "Maximum version must >= 9\n";
+ }
}
}
if (scanner->findOptionalTag("size:")) {
sscanf(scanner->getValue().c_str(), "%i", &intSize);
}
+
if (maxVersion > maxApiLevel) {
maxVersion = maxApiLevel;
}
+
return minVersion == 0 || minVersion <= maxApiLevel;
}
@@ -331,7 +341,7 @@
}
void ConstantSpecification::scanConstantSpecification(Scanner* scanner, SpecFile* specFile,
- int maxApiLevel) {
+ unsigned int maxApiLevel) {
string name = scanner->getValue();
VersionInfo info;
if (!info.scan(scanner, maxApiLevel)) {
@@ -357,7 +367,7 @@
}
void TypeSpecification::scanTypeSpecification(Scanner* scanner, SpecFile* specFile,
- int maxApiLevel) {
+ unsigned int maxApiLevel) {
string name = scanner->getValue();
VersionInfo info;
if (!info.scan(scanner, maxApiLevel)) {
@@ -522,7 +532,7 @@
}
}
-bool FunctionSpecification::hasTests(int versionOfTestFiles) const {
+bool FunctionSpecification::hasTests(unsigned int versionOfTestFiles) const {
if (mVersionInfo.maxVersion != 0 && mVersionInfo.maxVersion < versionOfTestFiles) {
return false;
}
@@ -533,7 +543,7 @@
}
void FunctionSpecification::scanFunctionSpecification(Scanner* scanner, SpecFile* specFile,
- int maxApiLevel) {
+ unsigned int maxApiLevel) {
// Some functions like convert have # part of the name. Truncate at that point.
const string& unexpandedName = scanner->getValue();
string name = unexpandedName;
@@ -562,6 +572,12 @@
spec->mTest = "scalar"; // default
spec->mVersionInfo = info;
+ if (scanner->findOptionalTag("internal:")) {
+ spec->mInternal = (scanner->getValue() == "true");
+ }
+ if (scanner->findOptionalTag("intrinsic:")) {
+ spec->mIntrinsic = (scanner->getValue() == "true");
+ }
if (scanner->findOptionalTag("attrib:")) {
spec->mAttribute = scanner->getValue();
}
@@ -711,7 +727,7 @@
}
// Read the specification, adding the definitions to the global functions map.
-bool SpecFile::readSpecFile(int maxApiLevel) {
+bool SpecFile::readSpecFile(unsigned int maxApiLevel) {
FILE* specFile = fopen(mSpecFileName.c_str(), "rt");
if (!specFile) {
cerr << "Error opening input file: " << mSpecFileName << "\n";
@@ -804,7 +820,7 @@
return findOrCreate<Function>(name, &mFunctions, created);
}
-bool SystemSpecification::readSpecFile(const string& fileName, int maxApiLevel) {
+bool SystemSpecification::readSpecFile(const string& fileName, unsigned int maxApiLevel) {
SpecFile* spec = new SpecFile(fileName);
if (!spec->readSpecFile(maxApiLevel)) {
cerr << fileName << ": Failed to parse.\n";
@@ -815,12 +831,16 @@
}
-static void updateMaxApiLevel(const VersionInfo& info, int* maxApiLevel) {
+static void updateMaxApiLevel(const VersionInfo& info, unsigned int* maxApiLevel) {
+ if (info.minVersion == VersionInfo::kUnreleasedVersion) {
+ // Ignore development API level in consideration of max API level.
+ return;
+ }
*maxApiLevel = max(*maxApiLevel, max(info.minVersion, info.maxVersion));
}
-int SystemSpecification::getMaximumApiLevel() {
- int maxApiLevel = 0;
+unsigned int SystemSpecification::getMaximumApiLevel() {
+ unsigned int maxApiLevel = 0;
for (auto i : mConstants) {
for (auto j: i.second->getSpecifications()) {
updateMaxApiLevel(j->getVersionInfo(), &maxApiLevel);
@@ -839,7 +859,7 @@
return maxApiLevel;
}
-bool SystemSpecification::generateFiles(bool forVerification, int maxApiLevel) const {
+bool SystemSpecification::generateFiles(bool forVerification, unsigned int maxApiLevel) const {
bool success = generateHeaderFiles("scriptc") &&
generateDocumentation("docs", forVerification) &&
generateTestFiles("test", maxApiLevel) &&