diff options
author | David Gross <dgross@google.com> | 2016-04-19 17:39:36 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-04-19 17:39:36 +0000 |
commit | 159c4cdb3d2798f6a916b86bbd7703b1a8a68e60 (patch) | |
tree | 0f647f2e666313aeda70877aa35aeec1e97c5522 | |
parent | 739c9a45e87054e82586c3f1215461db25f648a2 (diff) | |
parent | fe1e7ca3a7db3f62d38d5f824edac97ecdb1393d (diff) | |
download | slang-159c4cdb3d2798f6a916b86bbd7703b1a8a68e60.tar.gz |
Merge "General reduction should only support halter() at development API."
13 files changed, 366 insertions, 129 deletions
diff --git a/slang_rs_pragma_handler.cpp b/slang_rs_pragma_handler.cpp index bbedc36..065cb10 100644 --- a/slang_rs_pragma_handler.cpp +++ b/slang_rs_pragma_handler.cpp @@ -145,14 +145,18 @@ class RSReducePragmaHandler : public RSPragmaHandler { // Grab "reduce(name)" ("reduce" is already known to be the first // token) and all the "keyword(value)" contributions - // - // TODO: Remove halter from initial release KeywordValueMapType KeywordValueMap({std::make_pair(RSExportReduceNew::KeyReduce, ""), std::make_pair(RSExportReduceNew::KeyInitializer, ""), std::make_pair(RSExportReduceNew::KeyAccumulator, ""), std::make_pair(RSExportReduceNew::KeyCombiner, ""), - std::make_pair(RSExportReduceNew::KeyOutConverter, ""), - std::make_pair(RSExportReduceNew::KeyHalter, "")}); + std::make_pair(RSExportReduceNew::KeyOutConverter, "")}); + if (mContext->getTargetAPI() >= SLANG_FEATURE_GENERAL_REDUCTION_HALTER_API) { + // Halter functionality has not been released, nor has its + // specification been finalized with partners. We do not have a + // specification that extends through the full RenderScript + // software stack, either. + KeywordValueMap.insert(std::make_pair(RSExportReduceNew::KeyHalter, "")); + } while (PragmaToken.is(clang::tok::identifier)) { if (!ProcessKeywordAndValue(PP, PragmaToken, KeywordValueMap)) return; diff --git a/slang_version.h b/slang_version.h index 6594bb0..1580f93 100644 --- a/slang_version.h +++ b/slang_version.h @@ -52,7 +52,8 @@ enum SlangTargetAPI { // . Closed (feature exists only through a particular range of API levels): // SLANG_FEAT_BAR_API_MIN, SLANG_FEAT_BAR_API_MAX enum SlangFeatureAPI { - SLANG_FEATURE_GENERAL_REDUCTION_API = SLANG_N_TARGET_API + SLANG_FEATURE_GENERAL_REDUCTION_API = SLANG_N_TARGET_API, + SLANG_FEATURE_GENERAL_REDUCTION_HALTER_API = SLANG_DEVELOPMENT_TARGET_API }; // SlangVersion refers to the released compiler version (for which certain diff --git a/tests/F_reduce_general_bad_function/reduce_general_bad_function.rs b/tests/F_reduce_general_bad_function/reduce_general_bad_function.rs index d12ace0..b59800a 100644 --- a/tests/F_reduce_general_bad_function/reduce_general_bad_function.rs +++ b/tests/F_reduce_general_bad_function/reduce_general_bad_function.rs @@ -3,6 +3,7 @@ #pragma rs java_package_name(fn) // Various ways particular reduction consituent functions can fail semantic checks. +// Also see reduce_general_bad_halter.rs for halter function semantic checks. // Also see reduce_general_bad_accumulator.rs for accumulator data type checks. // trivial accumulator for use multiple times later @@ -253,51 +254,3 @@ static void out_const(const int *out, int *val) { } // . . . but outconverter parameter VALUES can be const #pragma rs reduce(out_valconst) accumulator(AccumInt) outconverter(out_valconst) static void out_valconst(int *const out, const int *val) { } - -///////////////////////////////////////////////////////////////////////////// -// halter -///////////////////////////////////////////////////////////////////////////// - -// halter must return bool -#pragma rs reduce(halt_void) accumulator(AccumInt) halter(halt_void) -static void halt_void(const int *accum) { } - -// halter must return bool -#pragma rs reduce(halt_int) accumulator(AccumInt) halter(halt_int) -static int halt_int(const int *accum) { return 0; } - -// halter must take exactly 1 parameter -#pragma rs reduce(halt0) accumulator(AccumInt) halter(halt0) -static bool halt0() { return false; } - -// halter must take exactly 1 parameter -#pragma rs reduce(halt2) accumulator(AccumInt) halter(halt2) -static bool halt2(const int *accum, const int *accum2) { return false; } - -// halter cannot take special parameter -#pragma rs reduce(halt_special) accumulator(AccumInt) halter(halt_special) -static bool halt_special(const int *context) { return false; } - -// halter and accumulator must take pointers to same type -#pragma rs reduce(halt_vs_accum) accumulator(AccumInt) halter(hva_halt) -static bool hva_halt(const unsigned *accum) { return false; } - -// halter may be overloadable . . . -#pragma rs reduce(halt_over) accumulator(AccumInt) halter(halt_over) -static __attribute__((overloadable)) bool halt_over(const int *accum) { return false; } - -// . . . but halter must not have duplicate definitions -#pragma rs reduce(halt_dup) accumulator(AccumInt) halter(halt_dup) -static __attribute__((overloadable)) bool halt_dup(const int *accum) { return false; } -static __attribute__((overloadable)) bool halt_dup(const unsigned int *accum) { return false; } - -// halter must be present -#pragma rs reduce(halt_missing) accumulator(AccumInt) halter(halt_missing) - -// halter must be static -#pragma rs reduce(halt_nonstatic) accumulator(AccumInt) halter(halt_nonstatic) -bool halt_nonstatic(const int *accum) { return false; } - -// halter parameter must point to const -#pragma rs reduce(halt_const) accumulator(AccumInt) halter(halt_const) -static bool halt_const(int *accum) { return false; } diff --git a/tests/F_reduce_general_bad_function/stderr.txt.expect b/tests/F_reduce_general_bad_function/stderr.txt.expect index ac74748..1e65259 100644 --- a/tests/F_reduce_general_bad_function/stderr.txt.expect +++ b/tests/F_reduce_general_bad_function/stderr.txt.expect @@ -1,61 +1,51 @@ -reduce_general_bad_function.rs:17:13: error: initializer init0() for '#pragma rs reduce(init0)' (reduce_general_bad_function.rs:16:12) must take exactly 1 parameter (found 0) -reduce_general_bad_function.rs:21:13: error: initializer init2() for '#pragma rs reduce(init2)' (reduce_general_bad_function.rs:20:12) must take exactly 1 parameter (found 2) -reduce_general_bad_function.rs:25:13: error: initializer init_special1() for '#pragma rs reduce(init_special1)' (reduce_general_bad_function.rs:24:12) cannot take special parameter 'x' -reduce_general_bad_function.rs:29:13: error: initializer init2_special1() for '#pragma rs reduce(init2_special1)' (reduce_general_bad_function.rs:28:12) must take exactly 1 parameter (found 2) -reduce_general_bad_function.rs:33:13: error: initializer init2_special0() for '#pragma rs reduce(init2_special0)' (reduce_general_bad_function.rs:32:12) must take exactly 1 parameter (found 2) -reduce_general_bad_function.rs:37:13: error: initializer init_noptr() for '#pragma rs reduce(init_noptr)' (reduce_general_bad_function.rs:36:12) parameter 'a' must be of pointer type not 'int' -reduce_general_bad_function.rs:44:12: error: duplicate function definition for 'initializer(init_dup)' for '#pragma rs reduce(init_dup)' (reduce_general_bad_function.rs:45:43, reduce_general_bad_function.rs:46:43) -reduce_general_bad_function.rs:49:12: error: could not find function definition for 'initializer(init_missing)' for '#pragma rs reduce(init_missing)' -reduce_general_bad_function.rs:53:6: error: initializer init_nonstatic() for '#pragma rs reduce(init_nonstatic)' (reduce_general_bad_function.rs:52:12) must be static -reduce_general_bad_function.rs:57:12: error: initializer init_nonvoid() for '#pragma rs reduce(init_nonvoid)' (reduce_general_bad_function.rs:56:12) must return void not 'int' -reduce_general_bad_function.rs:61:35: error: initializer init_const() for '#pragma rs reduce(init_const)' (reduce_general_bad_function.rs:60:12) parameter 'accum' (type 'const int *') must not point to const-qualified type -reduce_general_bad_function.rs:73:13: error: accumulator accum0() for '#pragma rs reduce(accum0)' (reduce_general_bad_function.rs:72:12) must take at least 2 parameters -reduce_general_bad_function.rs:77:13: error: accumulator accum1() for '#pragma rs reduce(accum1)' (reduce_general_bad_function.rs:76:12) must take at least 2 parameters -reduce_general_bad_function.rs:81:13: error: accumulator accum_noptr() for '#pragma rs reduce(accum_noptr)' (reduce_general_bad_function.rs:80:12) parameter 'accum' must be of pointer type not 'int' -reduce_general_bad_function.rs:86:13: error: accumulator avi_accum() for '#pragma rs reduce(accum_vs_init)' (reduce_general_bad_function.rs:84:12) parameter 'accum' (type 'double *') and initializer avi_init() parameter 'accum' (type 'int *') must be pointers to the same type -reduce_general_bad_function.rs:90:13: error: accumulator accum_special() for '#pragma rs reduce(accum_special)' (reduce_general_bad_function.rs:89:12) must have at least 1 input ('x' is a special parameter) -reduce_general_bad_function.rs:94:41: error: accumulator accum_ptr() for '#pragma rs reduce(accum_ptr)' (reduce_general_bad_function.rs:93:12) parameter 'val' (type 'char *') must not be a pointer -reduce_general_bad_function.rs:100:45: error: accumulator accum_arr() for '#pragma rs reduce(accum_arr)' (reduce_general_bad_function.rs:98:12) parameter 'val' (type 'char *') must not be a pointer -reduce_general_bad_function.rs:105:55: error: accumulator accum_obj() for '#pragma rs reduce(accum_obj)' (reduce_general_bad_function.rs:104:12) parameter 'elem' (type 'struct rs_element') must not contain an object type -reduce_general_bad_function.rs:113:12: error: duplicate function definition for 'accumulator(accum_dup)' for '#pragma rs reduce(accum_dup)' (reduce_general_bad_function.rs:114:43, reduce_general_bad_function.rs:115:43) -reduce_general_bad_function.rs:118:12: error: could not find function definition for 'accumulator(accum_missing)' for '#pragma rs reduce(accum_missing)' -reduce_general_bad_function.rs:122:6: error: accumulator accum_nonstatic() for '#pragma rs reduce(accum_nonstatic)' (reduce_general_bad_function.rs:121:12) must be static -reduce_general_bad_function.rs:126:12: error: accumulator accum_nonvoid() for '#pragma rs reduce(accum_nonvoid)' (reduce_general_bad_function.rs:125:12) must return void not 'int' -reduce_general_bad_function.rs:130:36: error: accumulator accum_const() for '#pragma rs reduce(accum_const)' (reduce_general_bad_function.rs:129:12) parameter 'accum' (type 'const int *') must not point to const-qualified type -reduce_general_bad_function.rs:142:13: error: combiner comb0() for '#pragma rs reduce(comb0)' (reduce_general_bad_function.rs:141:12) must take exactly 2 parameters (found 0) -reduce_general_bad_function.rs:146:13: error: combiner comb1() for '#pragma rs reduce(comb1)' (reduce_general_bad_function.rs:145:12) must take exactly 2 parameters (found 1) -reduce_general_bad_function.rs:150:13: error: combiner comb3() for '#pragma rs reduce(comb3)' (reduce_general_bad_function.rs:149:12) must take exactly 2 parameters (found 3) -reduce_general_bad_function.rs:155:13: error: combiner cva_comb() for '#pragma rs reduce(comb_vs_accum)' (reduce_general_bad_function.rs:153:12) parameter 'accum' (type 'unsigned int *') and accumulator cva_accum() parameter 'accum' (type 'int *') must be pointers to the same type -reduce_general_bad_function.rs:155:13: error: combiner cva_comb() for '#pragma rs reduce(comb_vs_accum)' (reduce_general_bad_function.rs:153:12) parameter 'other' (type 'const unsigned int *') and accumulator cva_accum() parameter 'accum' (type 'int *') must be pointers to the same type -reduce_general_bad_function.rs:159:13: error: accumulator accum_2in() for '#pragma rs reduce(accum_2in)' (reduce_general_bad_function.rs:158:12) must have exactly 1 input and no special parameters in order for the combiner to be omitted -reduce_general_bad_function.rs:163:13: error: accumulator accum_special_1in() for '#pragma rs reduce(accum_special_1in)' (reduce_general_bad_function.rs:162:12) must have exactly 1 input and no special parameters in order for the combiner to be omitted -reduce_general_bad_function.rs:167:13: error: accumulator accum_types() for '#pragma rs reduce(accum_types)' (reduce_general_bad_function.rs:166:12) parameter 'accum' (type 'int *') must be pointer to the type of parameter 'val' (type 'unsigned int') in order for the combiner to be omitted -reduce_general_bad_function.rs:174:12: error: duplicate function definition for 'combiner(comb_dup)' for '#pragma rs reduce(comb_dup)' (reduce_general_bad_function.rs:175:43, reduce_general_bad_function.rs:176:43) -reduce_general_bad_function.rs:179:12: error: could not find function definition for 'combiner(comb_missing)' for '#pragma rs reduce(comb_missing)' -reduce_general_bad_function.rs:183:6: error: combiner comb_nonstatic() for '#pragma rs reduce(comb_nonstatic)' (reduce_general_bad_function.rs:182:12) must be static -reduce_general_bad_function.rs:187:12: error: combiner comb_nonvoid() for '#pragma rs reduce(comb_nonvoid)' (reduce_general_bad_function.rs:186:12) must return void not 'int' -reduce_general_bad_function.rs:191:35: error: combiner comb_const() for '#pragma rs reduce(comb_const)' (reduce_general_bad_function.rs:190:12) parameter 'accum' (type 'const int *') must not point to const-qualified type -reduce_general_bad_function.rs:191:47: error: combiner comb_const() for '#pragma rs reduce(comb_const)' (reduce_general_bad_function.rs:190:12) parameter 'other' (type 'int *') must point to const-qualified type -reduce_general_bad_function.rs:203:13: error: outconverter out0() for '#pragma rs reduce(out0)' (reduce_general_bad_function.rs:202:12) must take exactly 2 parameters (found 0) -reduce_general_bad_function.rs:207:13: error: outconverter out1() for '#pragma rs reduce(out1)' (reduce_general_bad_function.rs:206:12) must take exactly 2 parameters (found 1) -reduce_general_bad_function.rs:211:13: error: outconverter out3() for '#pragma rs reduce(out3)' (reduce_general_bad_function.rs:210:12) must take exactly 2 parameters (found 3) -reduce_general_bad_function.rs:215:13: error: outconverter out_special() for '#pragma rs reduce(out_special)' (reduce_general_bad_function.rs:214:12) cannot take special parameter 'y' -reduce_general_bad_function.rs:219:13: error: outconverter out_ptr1() for '#pragma rs reduce(out_ptr1)' (reduce_general_bad_function.rs:218:12) parameter 'out' must be of pointer type not 'int' -reduce_general_bad_function.rs:223:13: error: outconverter out_ptr2() for '#pragma rs reduce(out_ptr2)' (reduce_general_bad_function.rs:222:12) parameter 'val' must be of pointer type not 'const int' -reduce_general_bad_function.rs:227:13: error: outconverter ova_out() for '#pragma rs reduce(out_vs_accum)' (reduce_general_bad_function.rs:226:12) parameter 'val' (type 'const double *') and accumulator AccumInt() parameter 'accum' (type 'int *') must be pointers to the same type -reduce_general_bad_function.rs:234:12: error: duplicate function definition for 'outconverter(out_dup)' for '#pragma rs reduce(out_dup)' (reduce_general_bad_function.rs:235:43, reduce_general_bad_function.rs:236:43) -reduce_general_bad_function.rs:239:12: error: could not find function definition for 'outconverter(out_missing)' for '#pragma rs reduce(out_missing)' -reduce_general_bad_function.rs:243:6: error: outconverter out_nonstatic() for '#pragma rs reduce(out_nonstatic)' (reduce_general_bad_function.rs:242:12) must be static -reduce_general_bad_function.rs:247:12: error: outconverter out_nonvoid() for '#pragma rs reduce(out_nonvoid)' (reduce_general_bad_function.rs:246:12) must return void not 'int' -reduce_general_bad_function.rs:251:34: error: outconverter out_const() for '#pragma rs reduce(out_const)' (reduce_general_bad_function.rs:250:12) parameter 'out' (type 'const int *') must not point to const-qualified type -reduce_general_bad_function.rs:251:44: error: outconverter out_const() for '#pragma rs reduce(out_const)' (reduce_general_bad_function.rs:250:12) parameter 'val' (type 'int *') must point to const-qualified type -reduce_general_bad_function.rs:263:13: error: halter halt_void() for '#pragma rs reduce(halt_void)' (reduce_general_bad_function.rs:262:12) must return bool not 'void' -reduce_general_bad_function.rs:267:12: error: halter halt_int() for '#pragma rs reduce(halt_int)' (reduce_general_bad_function.rs:266:12) must return bool not 'int' -reduce_general_bad_function.rs:271:13: error: halter halt0() for '#pragma rs reduce(halt0)' (reduce_general_bad_function.rs:270:12) must take exactly 1 parameter (found 0) -reduce_general_bad_function.rs:275:13: error: halter halt2() for '#pragma rs reduce(halt2)' (reduce_general_bad_function.rs:274:12) must take exactly 1 parameter (found 2) -reduce_general_bad_function.rs:279:13: error: halter halt_special() for '#pragma rs reduce(halt_special)' (reduce_general_bad_function.rs:278:12) cannot take special parameter 'context' -reduce_general_bad_function.rs:283:13: error: halter hva_halt() for '#pragma rs reduce(halt_vs_accum)' (reduce_general_bad_function.rs:282:12) parameter 'accum' (type 'const unsigned int *') and accumulator AccumInt() parameter 'accum' (type 'int *') must be pointers to the same type -reduce_general_bad_function.rs:290:12: error: duplicate function definition for 'halter(halt_dup)' for '#pragma rs reduce(halt_dup)' (reduce_general_bad_function.rs:291:43, reduce_general_bad_function.rs:292:43) -reduce_general_bad_function.rs:295:12: error: could not find function definition for 'halter(halt_missing)' for '#pragma rs reduce(halt_missing)' -reduce_general_bad_function.rs:299:6: error: halter halt_nonstatic() for '#pragma rs reduce(halt_nonstatic)' (reduce_general_bad_function.rs:298:12) must be static -reduce_general_bad_function.rs:303:29: error: halter halt_const() for '#pragma rs reduce(halt_const)' (reduce_general_bad_function.rs:302:12) parameter 'accum' (type 'int *') must point to const-qualified type +reduce_general_bad_function.rs:18:13: error: initializer init0() for '#pragma rs reduce(init0)' (reduce_general_bad_function.rs:17:12) must take exactly 1 parameter (found 0) +reduce_general_bad_function.rs:22:13: error: initializer init2() for '#pragma rs reduce(init2)' (reduce_general_bad_function.rs:21:12) must take exactly 1 parameter (found 2) +reduce_general_bad_function.rs:26:13: error: initializer init_special1() for '#pragma rs reduce(init_special1)' (reduce_general_bad_function.rs:25:12) cannot take special parameter 'x' +reduce_general_bad_function.rs:30:13: error: initializer init2_special1() for '#pragma rs reduce(init2_special1)' (reduce_general_bad_function.rs:29:12) must take exactly 1 parameter (found 2) +reduce_general_bad_function.rs:34:13: error: initializer init2_special0() for '#pragma rs reduce(init2_special0)' (reduce_general_bad_function.rs:33:12) must take exactly 1 parameter (found 2) +reduce_general_bad_function.rs:38:13: error: initializer init_noptr() for '#pragma rs reduce(init_noptr)' (reduce_general_bad_function.rs:37:12) parameter 'a' must be of pointer type not 'int' +reduce_general_bad_function.rs:45:12: error: duplicate function definition for 'initializer(init_dup)' for '#pragma rs reduce(init_dup)' (reduce_general_bad_function.rs:46:43, reduce_general_bad_function.rs:47:43) +reduce_general_bad_function.rs:50:12: error: could not find function definition for 'initializer(init_missing)' for '#pragma rs reduce(init_missing)' +reduce_general_bad_function.rs:54:6: error: initializer init_nonstatic() for '#pragma rs reduce(init_nonstatic)' (reduce_general_bad_function.rs:53:12) must be static +reduce_general_bad_function.rs:58:12: error: initializer init_nonvoid() for '#pragma rs reduce(init_nonvoid)' (reduce_general_bad_function.rs:57:12) must return void not 'int' +reduce_general_bad_function.rs:62:35: error: initializer init_const() for '#pragma rs reduce(init_const)' (reduce_general_bad_function.rs:61:12) parameter 'accum' (type 'const int *') must not point to const-qualified type +reduce_general_bad_function.rs:74:13: error: accumulator accum0() for '#pragma rs reduce(accum0)' (reduce_general_bad_function.rs:73:12) must take at least 2 parameters +reduce_general_bad_function.rs:78:13: error: accumulator accum1() for '#pragma rs reduce(accum1)' (reduce_general_bad_function.rs:77:12) must take at least 2 parameters +reduce_general_bad_function.rs:82:13: error: accumulator accum_noptr() for '#pragma rs reduce(accum_noptr)' (reduce_general_bad_function.rs:81:12) parameter 'accum' must be of pointer type not 'int' +reduce_general_bad_function.rs:87:13: error: accumulator avi_accum() for '#pragma rs reduce(accum_vs_init)' (reduce_general_bad_function.rs:85:12) parameter 'accum' (type 'double *') and initializer avi_init() parameter 'accum' (type 'int *') must be pointers to the same type +reduce_general_bad_function.rs:91:13: error: accumulator accum_special() for '#pragma rs reduce(accum_special)' (reduce_general_bad_function.rs:90:12) must have at least 1 input ('x' is a special parameter) +reduce_general_bad_function.rs:95:41: error: accumulator accum_ptr() for '#pragma rs reduce(accum_ptr)' (reduce_general_bad_function.rs:94:12) parameter 'val' (type 'char *') must not be a pointer +reduce_general_bad_function.rs:101:45: error: accumulator accum_arr() for '#pragma rs reduce(accum_arr)' (reduce_general_bad_function.rs:99:12) parameter 'val' (type 'char *') must not be a pointer +reduce_general_bad_function.rs:106:55: error: accumulator accum_obj() for '#pragma rs reduce(accum_obj)' (reduce_general_bad_function.rs:105:12) parameter 'elem' (type 'struct rs_element') must not contain an object type +reduce_general_bad_function.rs:114:12: error: duplicate function definition for 'accumulator(accum_dup)' for '#pragma rs reduce(accum_dup)' (reduce_general_bad_function.rs:115:43, reduce_general_bad_function.rs:116:43) +reduce_general_bad_function.rs:119:12: error: could not find function definition for 'accumulator(accum_missing)' for '#pragma rs reduce(accum_missing)' +reduce_general_bad_function.rs:123:6: error: accumulator accum_nonstatic() for '#pragma rs reduce(accum_nonstatic)' (reduce_general_bad_function.rs:122:12) must be static +reduce_general_bad_function.rs:127:12: error: accumulator accum_nonvoid() for '#pragma rs reduce(accum_nonvoid)' (reduce_general_bad_function.rs:126:12) must return void not 'int' +reduce_general_bad_function.rs:131:36: error: accumulator accum_const() for '#pragma rs reduce(accum_const)' (reduce_general_bad_function.rs:130:12) parameter 'accum' (type 'const int *') must not point to const-qualified type +reduce_general_bad_function.rs:143:13: error: combiner comb0() for '#pragma rs reduce(comb0)' (reduce_general_bad_function.rs:142:12) must take exactly 2 parameters (found 0) +reduce_general_bad_function.rs:147:13: error: combiner comb1() for '#pragma rs reduce(comb1)' (reduce_general_bad_function.rs:146:12) must take exactly 2 parameters (found 1) +reduce_general_bad_function.rs:151:13: error: combiner comb3() for '#pragma rs reduce(comb3)' (reduce_general_bad_function.rs:150:12) must take exactly 2 parameters (found 3) +reduce_general_bad_function.rs:156:13: error: combiner cva_comb() for '#pragma rs reduce(comb_vs_accum)' (reduce_general_bad_function.rs:154:12) parameter 'accum' (type 'unsigned int *') and accumulator cva_accum() parameter 'accum' (type 'int *') must be pointers to the same type +reduce_general_bad_function.rs:156:13: error: combiner cva_comb() for '#pragma rs reduce(comb_vs_accum)' (reduce_general_bad_function.rs:154:12) parameter 'other' (type 'const unsigned int *') and accumulator cva_accum() parameter 'accum' (type 'int *') must be pointers to the same type +reduce_general_bad_function.rs:160:13: error: accumulator accum_2in() for '#pragma rs reduce(accum_2in)' (reduce_general_bad_function.rs:159:12) must have exactly 1 input and no special parameters in order for the combiner to be omitted +reduce_general_bad_function.rs:164:13: error: accumulator accum_special_1in() for '#pragma rs reduce(accum_special_1in)' (reduce_general_bad_function.rs:163:12) must have exactly 1 input and no special parameters in order for the combiner to be omitted +reduce_general_bad_function.rs:168:13: error: accumulator accum_types() for '#pragma rs reduce(accum_types)' (reduce_general_bad_function.rs:167:12) parameter 'accum' (type 'int *') must be pointer to the type of parameter 'val' (type 'unsigned int') in order for the combiner to be omitted +reduce_general_bad_function.rs:175:12: error: duplicate function definition for 'combiner(comb_dup)' for '#pragma rs reduce(comb_dup)' (reduce_general_bad_function.rs:176:43, reduce_general_bad_function.rs:177:43) +reduce_general_bad_function.rs:180:12: error: could not find function definition for 'combiner(comb_missing)' for '#pragma rs reduce(comb_missing)' +reduce_general_bad_function.rs:184:6: error: combiner comb_nonstatic() for '#pragma rs reduce(comb_nonstatic)' (reduce_general_bad_function.rs:183:12) must be static +reduce_general_bad_function.rs:188:12: error: combiner comb_nonvoid() for '#pragma rs reduce(comb_nonvoid)' (reduce_general_bad_function.rs:187:12) must return void not 'int' +reduce_general_bad_function.rs:192:35: error: combiner comb_const() for '#pragma rs reduce(comb_const)' (reduce_general_bad_function.rs:191:12) parameter 'accum' (type 'const int *') must not point to const-qualified type +reduce_general_bad_function.rs:192:47: error: combiner comb_const() for '#pragma rs reduce(comb_const)' (reduce_general_bad_function.rs:191:12) parameter 'other' (type 'int *') must point to const-qualified type +reduce_general_bad_function.rs:204:13: error: outconverter out0() for '#pragma rs reduce(out0)' (reduce_general_bad_function.rs:203:12) must take exactly 2 parameters (found 0) +reduce_general_bad_function.rs:208:13: error: outconverter out1() for '#pragma rs reduce(out1)' (reduce_general_bad_function.rs:207:12) must take exactly 2 parameters (found 1) +reduce_general_bad_function.rs:212:13: error: outconverter out3() for '#pragma rs reduce(out3)' (reduce_general_bad_function.rs:211:12) must take exactly 2 parameters (found 3) +reduce_general_bad_function.rs:216:13: error: outconverter out_special() for '#pragma rs reduce(out_special)' (reduce_general_bad_function.rs:215:12) cannot take special parameter 'y' +reduce_general_bad_function.rs:220:13: error: outconverter out_ptr1() for '#pragma rs reduce(out_ptr1)' (reduce_general_bad_function.rs:219:12) parameter 'out' must be of pointer type not 'int' +reduce_general_bad_function.rs:224:13: error: outconverter out_ptr2() for '#pragma rs reduce(out_ptr2)' (reduce_general_bad_function.rs:223:12) parameter 'val' must be of pointer type not 'const int' +reduce_general_bad_function.rs:228:13: error: outconverter ova_out() for '#pragma rs reduce(out_vs_accum)' (reduce_general_bad_function.rs:227:12) parameter 'val' (type 'const double *') and accumulator AccumInt() parameter 'accum' (type 'int *') must be pointers to the same type +reduce_general_bad_function.rs:235:12: error: duplicate function definition for 'outconverter(out_dup)' for '#pragma rs reduce(out_dup)' (reduce_general_bad_function.rs:236:43, reduce_general_bad_function.rs:237:43) +reduce_general_bad_function.rs:240:12: error: could not find function definition for 'outconverter(out_missing)' for '#pragma rs reduce(out_missing)' +reduce_general_bad_function.rs:244:6: error: outconverter out_nonstatic() for '#pragma rs reduce(out_nonstatic)' (reduce_general_bad_function.rs:243:12) must be static +reduce_general_bad_function.rs:248:12: error: outconverter out_nonvoid() for '#pragma rs reduce(out_nonvoid)' (reduce_general_bad_function.rs:247:12) must return void not 'int' +reduce_general_bad_function.rs:252:34: error: outconverter out_const() for '#pragma rs reduce(out_const)' (reduce_general_bad_function.rs:251:12) parameter 'out' (type 'const int *') must not point to const-qualified type +reduce_general_bad_function.rs:252:44: error: outconverter out_const() for '#pragma rs reduce(out_const)' (reduce_general_bad_function.rs:251:12) parameter 'val' (type 'int *') must point to const-qualified type diff --git a/tests/F_reduce_general_bad_halter/reduce_general_bad_halter.rs b/tests/F_reduce_general_bad_halter/reduce_general_bad_halter.rs new file mode 100644 index 0000000..b7de60c --- /dev/null +++ b/tests/F_reduce_general_bad_halter/reduce_general_bad_halter.rs @@ -0,0 +1,58 @@ +// -Wall -target-api 0 +#pragma version(1) +#pragma rs java_package_name(fn) + +// Various ways halter can fail semantic checks. +// Also see reduce_general_bad_function.rs for other constituent function semantic checks. +// Also see reduce_general_bad_accumulator.rs for accumulator data type checks. + +// trivial accumulator for use multiple times later +static void AccumInt(int *accum, int val) { } + +///////////////////////////////////////////////////////////////////////////// +// halter +///////////////////////////////////////////////////////////////////////////// + +// halter must return bool +#pragma rs reduce(halt_void) accumulator(AccumInt) halter(halt_void) +static void halt_void(const int *accum) { } + +// halter must return bool +#pragma rs reduce(halt_int) accumulator(AccumInt) halter(halt_int) +static int halt_int(const int *accum) { return 0; } + +// halter must take exactly 1 parameter +#pragma rs reduce(halt0) accumulator(AccumInt) halter(halt0) +static bool halt0() { return false; } + +// halter must take exactly 1 parameter +#pragma rs reduce(halt2) accumulator(AccumInt) halter(halt2) +static bool halt2(const int *accum, const int *accum2) { return false; } + +// halter cannot take special parameter +#pragma rs reduce(halt_special) accumulator(AccumInt) halter(halt_special) +static bool halt_special(const int *context) { return false; } + +// halter and accumulator must take pointers to same type +#pragma rs reduce(halt_vs_accum) accumulator(AccumInt) halter(hva_halt) +static bool hva_halt(const unsigned *accum) { return false; } + +// halter may be overloadable . . . +#pragma rs reduce(halt_over) accumulator(AccumInt) halter(halt_over) +static __attribute__((overloadable)) bool halt_over(const int *accum) { return false; } + +// . . . but halter must not have duplicate definitions +#pragma rs reduce(halt_dup) accumulator(AccumInt) halter(halt_dup) +static __attribute__((overloadable)) bool halt_dup(const int *accum) { return false; } +static __attribute__((overloadable)) bool halt_dup(const unsigned int *accum) { return false; } + +// halter must be present +#pragma rs reduce(halt_missing) accumulator(AccumInt) halter(halt_missing) + +// halter must be static +#pragma rs reduce(halt_nonstatic) accumulator(AccumInt) halter(halt_nonstatic) +bool halt_nonstatic(const int *accum) { return false; } + +// halter parameter must point to const +#pragma rs reduce(halt_const) accumulator(AccumInt) halter(halt_const) +static bool halt_const(int *accum) { return false; } diff --git a/tests/F_reduce_general_bad_halter/stderr.txt.expect b/tests/F_reduce_general_bad_halter/stderr.txt.expect new file mode 100644 index 0000000..d96207e --- /dev/null +++ b/tests/F_reduce_general_bad_halter/stderr.txt.expect @@ -0,0 +1,10 @@ +reduce_general_bad_halter.rs:18:13: error: halter halt_void() for '#pragma rs reduce(halt_void)' (reduce_general_bad_halter.rs:17:12) must return bool not 'void' +reduce_general_bad_halter.rs:22:12: error: halter halt_int() for '#pragma rs reduce(halt_int)' (reduce_general_bad_halter.rs:21:12) must return bool not 'int' +reduce_general_bad_halter.rs:26:13: error: halter halt0() for '#pragma rs reduce(halt0)' (reduce_general_bad_halter.rs:25:12) must take exactly 1 parameter (found 0) +reduce_general_bad_halter.rs:30:13: error: halter halt2() for '#pragma rs reduce(halt2)' (reduce_general_bad_halter.rs:29:12) must take exactly 1 parameter (found 2) +reduce_general_bad_halter.rs:34:13: error: halter halt_special() for '#pragma rs reduce(halt_special)' (reduce_general_bad_halter.rs:33:12) cannot take special parameter 'context' +reduce_general_bad_halter.rs:38:13: error: halter hva_halt() for '#pragma rs reduce(halt_vs_accum)' (reduce_general_bad_halter.rs:37:12) parameter 'accum' (type 'const unsigned int *') and accumulator AccumInt() parameter 'accum' (type 'int *') must be pointers to the same type +reduce_general_bad_halter.rs:45:12: error: duplicate function definition for 'halter(halt_dup)' for '#pragma rs reduce(halt_dup)' (reduce_general_bad_halter.rs:46:43, reduce_general_bad_halter.rs:47:43) +reduce_general_bad_halter.rs:50:12: error: could not find function definition for 'halter(halt_missing)' for '#pragma rs reduce(halt_missing)' +reduce_general_bad_halter.rs:54:6: error: halter halt_nonstatic() for '#pragma rs reduce(halt_nonstatic)' (reduce_general_bad_halter.rs:53:12) must be static +reduce_general_bad_halter.rs:58:29: error: halter halt_const() for '#pragma rs reduce(halt_const)' (reduce_general_bad_halter.rs:57:12) parameter 'accum' (type 'int *') must point to const-qualified type diff --git a/tests/F_reduce_general_bad_halter/stdout.txt.expect b/tests/F_reduce_general_bad_halter/stdout.txt.expect new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/F_reduce_general_bad_halter/stdout.txt.expect diff --git a/tests/F_reduce_general_parse/stderr.txt.expect b/tests/F_reduce_general_parse/stderr.txt.expect index fc64dd8..b21b78c 100644 --- a/tests/F_reduce_general_parse/stderr.txt.expect +++ b/tests/F_reduce_general_parse/stderr.txt.expect @@ -10,5 +10,5 @@ reduce_general_parse.rs:13:12: error: missing 'accumulator' for '#pragma rs redu reduce_general_parse.rs:15:12: error: reduction kernel 'foo' declared multiple times (first one is at reduce_general_parse.rs:14:12) reduce_general_parse.rs:17:63: error: more than one 'accumulator' for '#pragma rs reduce' reduce_general_parse.rs:18:63: error: more than one 'accumulator' for '#pragma rs reduce' -reduce_general_parse.rs:19:24: error: did not recognize 'something' for '#pragma reduce'; expected one of the following keywords: 'accumulator', 'combiner', 'halter', 'initializer', 'outconverter', 'reduce' +reduce_general_parse.rs:19:24: error: did not recognize 'something' for '#pragma reduce'; expected one of the following keywords: 'accumulator', 'combiner', 'initializer', 'outconverter', 'reduce' reduce_general_parse.rs:20:56: error: did not expect '(' here for '#pragma rs reduce' diff --git a/tests/P_reduce_general_examples/reduce_general_examples.rs b/tests/P_reduce_general_examples/reduce_general_examples.rs index 83f88aa..17b6a27 100644 --- a/tests/P_reduce_general_examples/reduce_general_examples.rs +++ b/tests/P_reduce_general_examples/reduce_general_examples.rs @@ -85,8 +85,7 @@ static void fMMOutConverter(int2 *result, #pragma rs reduce(fz) \ initializer(fzInit) \ - accumulator(fzAccum) combiner(fzCombine) \ - halter(fzFound) + accumulator(fzAccum) combiner(fzCombine) static void fzInit(int *accumIdx) { *accumIdx = -1; } @@ -99,17 +98,11 @@ static void fzCombine(int *accumIdx, const int *accumIdx2) { if (*accumIdx2 >= 0) *accumIdx = *accumIdx2; } -// halter function -static bool fzFound(const int *accumIdx) { - return *accumIdx >= 0; -} - ///////////////////////////////////////////////////////////////////////// #pragma rs reduce(fz2) \ initializer(fz2Init) \ - accumulator(fz2Accum) combiner(fz2Combine) \ - halter(fz2Found) + accumulator(fz2Accum) combiner(fz2Combine) static void fz2Init(int2 *accum) { accum->x = accum->y = -1; } @@ -127,11 +120,6 @@ static void fz2Combine(int2 *accum, const int2 *accum2) { if (accum2->x >= 0) *accum = *accum2; } -// halter function -static bool fz2Found(const int2 *accum) { - return accum->x >= 0; -} - ///////////////////////////////////////////////////////////////////////// #pragma rs reduce(histogram) \ diff --git a/tests/P_reduce_general_examples_halter/ScriptC_reduce_general_examples_halter.java.expect b/tests/P_reduce_general_examples_halter/ScriptC_reduce_general_examples_halter.java.expect new file mode 100644 index 0000000..d49c116 --- /dev/null +++ b/tests/P_reduce_general_examples_halter/ScriptC_reduce_general_examples_halter.java.expect @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2011-2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * This file is auto-generated. DO NOT MODIFY! + * The source Renderscript file: reduce_general_examples_halter.rs + */ + +package examples; + +import android.renderscript.*; +import examples.reduce_general_examples_halterBitCode; + +/** + * @hide + */ +public class ScriptC_reduce_general_examples_halter extends ScriptC { + private static final String __rs_resource_name = "reduce_general_examples_halter"; + // Constructor + public ScriptC_reduce_general_examples_halter(RenderScript rs) { + super(rs, + __rs_resource_name, + reduce_general_examples_halterBitCode.getBitCode32(), + reduce_general_examples_halterBitCode.getBitCode64()); + mRSLocal = rs; + __I32 = Element.I32(rs); + __I32_2 = Element.I32_2(rs); + } + + private Element __I32; + private Element __I32_2; + private RenderScript mRSLocal; + // To obtain the result, invoke get(), which blocks + // until the asynchronously-launched operation has completed. + public static class result_int { + public int get() { + int[] outArray = new int[1]; + mOut.copyTo(outArray); + return outArray[0]; + } + + private result_int(Allocation out) { + mOut = out; + } + + private Allocation mOut; + } + + // To obtain the result, invoke get(), which blocks + // until the asynchronously-launched operation has completed. + public static class result_int2 { + public Int2 get() { + int[] outArray = new int[2]; + mOut.copyTo(outArray); + return new Int2(outArray[0], outArray[1]); + } + + private result_int2(Allocation out) { + mOut = out; + } + + private Allocation mOut; + } + + private final static int mExportReduceNewIdx_fz = 0; + // in1 = "inVal" + public result_int reduce_fz(int[] in1) { + // Verify that "in1" is non-null. + if (in1 == null) { + throw new RSIllegalArgumentException("Array \"in1\" is null!"); + } + + return reduce_fz(in1, 0, in1.length); + } + + // reduction only across cells at x1 <= coord < x2 + // in1 = "inVal" + public result_int reduce_fz(int[] in1, int x1, int x2) { + // Bounds-check x1 and x2 + if (x1 < 0 || x1 >= x2) { + throw new RSRuntimeException("Input bounds are invalid!"); + } + // Verify that "in1" is non-null. + if (in1 == null) { + throw new RSIllegalArgumentException("Array \"in1\" is null!"); + } + // Bounds-check "in1" against x2 + if (x2 > in1.length) { + throw new RSRuntimeException("Input bound is invalid for parameter \"in1\"!"); + } + Allocation ain1 = Allocation.createSized(mRSLocal, __I32, x2 - x1); + ain1.setAutoPadding(true); + ain1.copy1DRangeFrom(x1, x2 - x1, in1); + + return reduce_fz(ain1, null); + } + + // ain1 = "int inVal" + public result_int reduce_fz(Allocation ain1) { + return reduce_fz(ain1, null); + } + + // ain1 = "int inVal" + public result_int reduce_fz(Allocation ain1, Script.LaunchOptions sc) { + // check ain1 + if (!ain1.getType().getElement().isCompatible(__I32)) { + throw new RSRuntimeException("Type mismatch with I32!"); + } + Allocation aout = Allocation.createSized(mRSLocal, __I32, 1); + aout.setAutoPadding(true); + reduce(mExportReduceNewIdx_fz, new Allocation[]{ain1}, aout, sc); + return new result_int(aout); + } + + private final static int mExportReduceNewIdx_fz2 = 1; + // in1 = "inVal" + public result_int2 reduce_fz2(int[] in1) { + // Verify that "in1" is non-null. + if (in1 == null) { + throw new RSIllegalArgumentException("Array \"in1\" is null!"); + } + + return reduce_fz2(in1, 0, in1.length); + } + + // reduction only across cells at x1 <= coord < x2 + // in1 = "inVal" + public result_int2 reduce_fz2(int[] in1, int x1, int x2) { + // Bounds-check x1 and x2 + if (x1 < 0 || x1 >= x2) { + throw new RSRuntimeException("Input bounds are invalid!"); + } + // Verify that "in1" is non-null. + if (in1 == null) { + throw new RSIllegalArgumentException("Array \"in1\" is null!"); + } + // Bounds-check "in1" against x2 + if (x2 > in1.length) { + throw new RSRuntimeException("Input bound is invalid for parameter \"in1\"!"); + } + Allocation ain1 = Allocation.createSized(mRSLocal, __I32, x2 - x1); + ain1.setAutoPadding(true); + ain1.copy1DRangeFrom(x1, x2 - x1, in1); + + return reduce_fz2(ain1, null); + } + + // ain1 = "int inVal" + public result_int2 reduce_fz2(Allocation ain1) { + return reduce_fz2(ain1, null); + } + + // ain1 = "int inVal" + public result_int2 reduce_fz2(Allocation ain1, Script.LaunchOptions sc) { + // check ain1 + if (!ain1.getType().getElement().isCompatible(__I32)) { + throw new RSRuntimeException("Type mismatch with I32!"); + } + Allocation aout = Allocation.createSized(mRSLocal, __I32_2, 1); + aout.setAutoPadding(true); + reduce(mExportReduceNewIdx_fz2, new Allocation[]{ain1}, aout, sc); + return new result_int2(aout); + } + +} + diff --git a/tests/P_reduce_general_examples_halter/reduce_general_examples_halter.rs b/tests/P_reduce_general_examples_halter/reduce_general_examples_halter.rs new file mode 100644 index 0000000..8e35fe0 --- /dev/null +++ b/tests/P_reduce_general_examples_halter/reduce_general_examples_halter.rs @@ -0,0 +1,54 @@ +// -Wall -Werror -target-api 0 +#pragma version(1) +#pragma rs java_package_name(examples) + +///////////////////////////////////////////////////////////////////////// + +#pragma rs reduce(fz) \ + initializer(fzInit) \ + accumulator(fzAccum) combiner(fzCombine) \ + halter(fzFound) + +static void fzInit(int *accumIdx) { *accumIdx = -1; } + +static void fzAccum(int *accumIdx, + int inVal, int x /* special arg */) { + if (inVal==0) *accumIdx = x; +} + +static void fzCombine(int *accumIdx, const int *accumIdx2) { + if (*accumIdx2 >= 0) *accumIdx = *accumIdx2; +} + +// halter function +static bool fzFound(const int *accumIdx) { + return *accumIdx >= 0; +} + +///////////////////////////////////////////////////////////////////////// + +#pragma rs reduce(fz2) \ + initializer(fz2Init) \ + accumulator(fz2Accum) combiner(fz2Combine) \ + halter(fz2Found) + +static void fz2Init(int2 *accum) { accum->x = accum->y = -1; } + +static void fz2Accum(int2 *accum, + int inVal, + int x /* special arg */, + int y /* special arg */) { + if (inVal==0) { + accum->x = x; + accum->y = y; + } +} + +static void fz2Combine(int2 *accum, const int2 *accum2) { + if (accum2->x >= 0) *accum = *accum2; +} + +// halter function +static bool fz2Found(const int2 *accum) { + return accum->x >= 0; +} diff --git a/tests/P_reduce_general_examples_halter/stderr.txt.expect b/tests/P_reduce_general_examples_halter/stderr.txt.expect new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/P_reduce_general_examples_halter/stderr.txt.expect diff --git a/tests/P_reduce_general_examples_halter/stdout.txt.expect b/tests/P_reduce_general_examples_halter/stdout.txt.expect new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/P_reduce_general_examples_halter/stdout.txt.expect |