diff --git a/compiler/llvm/clangUtil.cpp b/compiler/llvm/clangUtil.cpp index ce4561a87d36..46a296f2d8b3 100644 --- a/compiler/llvm/clangUtil.cpp +++ b/compiler/llvm/clangUtil.cpp @@ -2666,6 +2666,10 @@ static std::string generateClangGpuLangArgs() { args += " -lstdc++"; break; } + + if (gpuArches.size() >= 1) { + args += " " + std::string("--offload-arch=") + *gpuArches.begin(); + } } return args; } @@ -2911,11 +2915,6 @@ void runClang(const char* just_parse_filename) { // Need to select CUDA/AMD mode in embedded clang to // activate the GPU target splitStringWhitespace(generateClangGpuLangArgs(), clangOtherArgs); - - if (gpuArches.size() >= 1) { - std::string archFlag = std::string("--offload-arch=") + *gpuArches.begin(); - clangOtherArgs.push_back(archFlag); - } } // Always include sys_basic because it might change the diff --git a/compiler/passes/buildDefaultFunctions.cpp b/compiler/passes/buildDefaultFunctions.cpp index 2d4ee3df1bd6..cdccafd16041 100644 --- a/compiler/passes/buildDefaultFunctions.cpp +++ b/compiler/passes/buildDefaultFunctions.cpp @@ -1867,6 +1867,9 @@ static void buildDefaultReadWriteFunctions(AggregateType* ct) { bool makeReadThisAndWriteThis = true; bool hasSerialize = false; + bool hasDeserialize = false; + bool AnySerialize = false; + FnSymbol* readerInit = nullptr; // Always build for 'object' to satisfy 'override' keyword in some cases. bool makeSerialize = ct == dtObject || !fNoIOGenSerialization; @@ -1889,16 +1892,49 @@ static void buildDefaultReadWriteFunctions(AggregateType* ct) { if (isArrayImplType(ct)) return; - if (functionExists("writeThis", dtMethodToken, ct, dtAny)) { + if (functionExists("deserialize", dtMethodToken, ct, dtAny, dtAny)) { + hasDeserialize = true; + } + + if (functionExists("serialize", dtMethodToken, ct, dtAny, dtAny)) { + hasSerialize = true; + } + + // TODO: should these say something about the type declared on? + if (FnSymbol* fn = functionExists("writeThis", dtMethodToken, ct, dtAny)) { + if (hasSerialize == false) { + USR_WARN(fn, "'writeThis' is deprecated. Please use 'serialize' methods instead."); + } hasWriteThis = true; } - if (functionExists("readThis", dtMethodToken, ct, dtAny)) { + if (FnSymbol* fn = functionExists("readThis", dtMethodToken, ct, dtAny)) { + if (hasDeserialize == false) { + USR_WARN(fn, "'readThis' is deprecated. Please use 'deserialize' methods instead."); + } hasReadThis = true; } - if (functionExists("serialize", dtMethodToken, ct, dtAny, dtAny)) { - hasSerialize = true; + forv_Vec(FnSymbol, method, ct->methods) { + if (method != nullptr && + method->isInitializer() && + method->numFormals() == 4 && + strcmp(method->getFormal(3)->name, "reader") == 0 && + strcmp(method->getFormal(4)->name, "deserializer") == 0) { + readerInit = method; + break; + } + } + + if (hasSerialize || hasDeserialize || + (readerInit != nullptr && + readerInit->hasFlag(FLAG_COMPILER_GENERATED) == false && + ct->getModule()->modTag != MOD_INTERNAL)) { + // If there's a user-defined 'serialize' method... + // Or a user-defined 'deserialize' method... + // Or a user-defined 'init'-deserializing method... + // Then do not generate anything (except for hinting compiler errors) + AnySerialize = true; } // We'll make a writeThis and a readThis if neither exist. @@ -1944,6 +1980,9 @@ static void buildDefaultReadWriteFunctions(AggregateType* ct) { // TODO: we probably want to have a warning here to help users migrate // their code to use formatters. fn->insertAtTail(new CallExpr("writeThis", gMethodToken, fn->_this, fileArg)); + } else if (AnySerialize) { + auto msg = new_StringSymbol("'serialize' methods are not compiler-generated when a type has a user-defined 'deserialize' method."); + fn->insertAtTail(new CallExpr("compilerError", msg)); } else { fn->insertAtTail(new CallExpr("serializeDefaultImpl", fileArg, @@ -1971,8 +2010,7 @@ static void buildDefaultReadWriteFunctions(AggregateType* ct) { } bool makeDeserialize = ct == dtObject || !fNoIOGenSerialization; - if (makeDeserialize && - !functionExists("deserialize", dtMethodToken, ct, dtAny, dtAny)) { + if (makeDeserialize && !hasDeserialize) { ArgSymbol* fileArg = NULL; FnSymbol* fn = buildReadThisFnSymbol(ct, &fileArg, "deserialize"); @@ -1987,6 +2025,9 @@ static void buildDefaultReadWriteFunctions(AggregateType* ct) { gMethodToken, fn->_this, fileArg)); + } else if (AnySerialize) { + auto msg = new_StringSymbol("'deserialize' methods are not compiler-generated when a type has a user-defined 'serialize' method."); + fn->insertAtTail(new CallExpr("compilerError", msg)); } else { VarSymbol* temp = newTemp("_deser_temp"); fn->insertAtTail(new DefExpr(temp)); @@ -1999,6 +2040,11 @@ static void buildDefaultReadWriteFunctions(AggregateType* ct) { normalize(fn); } + + if (ct->builtReaderInit && AnySerialize && readerInit != nullptr) { + auto msg = new_StringSymbol("Initializers called by IO for deserialization are not compiler-generated when a user-defined 'serialize' or 'deserialize' method exists"); + readerInit->insertAtHead(new CallExpr("compilerError", msg)); + } } diff --git a/compiler/passes/normalize.cpp b/compiler/passes/normalize.cpp index 981f6daa9320..94a876be266f 100644 --- a/compiler/passes/normalize.cpp +++ b/compiler/passes/normalize.cpp @@ -103,6 +103,7 @@ static void normalizeCallToTypeConstructor(CallExpr* call); static void applyGetterTransform(CallExpr* call); static void transformIfVar(CallExpr* call); static void insertCallTemps(CallExpr* call); +static void propagateMarkedGeneric(Symbol* var, Expr* typeExpr); static Symbol* insertCallTempsWithStmt(CallExpr* call, Expr* stmt); static void errorIfSplitInitializationRequired(DefExpr* def, Expr* cur); @@ -1725,6 +1726,7 @@ static void addTypeBlocksForParentTypeOf(CallExpr* call) { ************************************** | *************************************/ static void fixupExportedArrayReturns(FnSymbol* fn); +static void fixupGenericReturnTypes(FnSymbol* fn); static bool isVoidReturn(CallExpr* call); static bool hasGenericArrayReturn(FnSymbol* fn); static void insertRetMove(FnSymbol* fn, VarSymbol* retval, CallExpr* ret, @@ -1736,6 +1738,7 @@ static void normalizeReturns(FnSymbol* fn) { SET_LINENO(fn); fixupExportedArrayReturns(fn); + fixupGenericReturnTypes(fn); std::vector rets; std::vector calls; @@ -1911,6 +1914,32 @@ static void fixupExportedArrayReturns(FnSymbol* fn) { } } +// If the return type was declared generic e.g. as R(?), then +// mark the function with FLAG_RET_TYPE_MARKED_GENERIC. +// Also simplifies the simplest case to help with problems with +// proc f(): domain(?) { ... } +static void fixupGenericReturnTypes(FnSymbol* fn) { + if (fn->retExprType) { + // handle nested cases, e.g. (GenericRecord(?), ) or borrowed GenCls(?) + propagateMarkedGeneric(fn, fn->retExprType); + + // simpify the simple case + Expr* tail = fn->retExprType->body.tail; + if (CallExpr* call = toCallExpr(tail)) { + if (call->numActuals() == 1) { + if (SymExpr* se = toSymExpr(call->get(1))) { + if (call->baseExpr && se->symbol() == gUninstantiated) { + Expr* type = call->baseExpr->remove(); + tail->replace(type); + // flag should have been added in propagateMarkedGeneric + INT_ASSERT(fn->hasFlag(FLAG_RET_TYPE_MARKED_GENERIC)); + } + } + } + } + } +} + static void normalizeYields(FnSymbol* fn) { INT_ASSERT(fn->isIterator()); SET_LINENO(fn); @@ -2485,15 +2514,18 @@ static void insertCallTemps(CallExpr* call) { } } -// adds FLAG_MARKED_GENERIC to 'var' if the type contains a ? +// adds FLAG_MARKED_GENERIC/FLAG_RET_TYPE_MARKED_GENERIC +// to 'var' if the type contains a ? // actual or an actual that is a temp marked with that flag. static void propagateMarkedGeneric(Symbol* var, Expr* typeExpr) { if (SymExpr* se = toSymExpr(typeExpr)) { Symbol* sym = se->symbol(); if (sym == gUninstantiated || (sym->hasFlag(FLAG_MARKED_GENERIC) && sym->hasFlag(FLAG_TEMP))) { - var->addFlag(FLAG_MARKED_GENERIC); - // printf("(A) Adding FLAG_MARKED_GENERIC to %s\n", sym->name); + if (isFnSymbol(var)) + var->addFlag(FLAG_RET_TYPE_MARKED_GENERIC); + else + var->addFlag(FLAG_MARKED_GENERIC); } } else if (CallExpr* call = toCallExpr(typeExpr)) { if (call->baseExpr) @@ -2502,6 +2534,11 @@ static void propagateMarkedGeneric(Symbol* var, Expr* typeExpr) { for_actuals(actual, call) { propagateMarkedGeneric(var, actual); } + } else if (BlockStmt* blk = toBlockStmt(typeExpr)) { + // handle blocks since they are used for return type exprs + for_alist(expr, blk->body) { + propagateMarkedGeneric(var, expr); + } } } @@ -3476,6 +3513,15 @@ void warnIfGenericFormalMissingQ(ArgSymbol* arg, Type* type, Expr* typeExpr) { } } } + + // error for CR(?) where CR is a concrete record or class type + if (!type->symbol->hasFlag(FLAG_GENERIC) && + arg->hasFlag(FLAG_MARKED_GENERIC)) { + USR_FATAL(arg, + "the formal argument '%s' is marked generic with (?) " + "but the type '%s' is not generic", + arg->name, toString(type, /*decorators*/ false)); + } } static void hack_resolve_types(ArgSymbol* arg) { diff --git a/compiler/resolution/callInfo.cpp b/compiler/resolution/callInfo.cpp index eea2f79627ea..f684c0324dad 100644 --- a/compiler/resolution/callInfo.cpp +++ b/compiler/resolution/callInfo.cpp @@ -192,6 +192,9 @@ const char* CallInfo::toString() { ii->iterator->hasFlag(FLAG_PROMOTION_WRAPPER) == true) { retval = astr(retval, "promoted expression"); + } else if (sym == gUninstantiated) { + retval = astr(retval, "?"); + } else if (sym->hasFlag(FLAG_TYPE_VARIABLE) == true) { retval = astr(retval, "type ", ::toString(type)); diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 0d4cf8d80eae..873a828bc98a 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -13883,6 +13883,42 @@ void checkDuplicateDecorators(Type* decorator, Type* decorated, Expr* ctx) { std::set gAlreadyWarnedSurprisingGenericSyms; std::set gAlreadyWarnedSurprisingGenericManagementSyms; +static bool computeIsField(Symbol*& sym, AggregateType* forFieldInHere) { + // is it a field? check to see if it's a temp within an initializer + // initializing field (in which case, we should think about + // this as a field). If it's a field, replaces 'sym' with the + // field to use for error reporting. + bool isField = false; + + if (forFieldInHere) { + AggregateType* ct = forFieldInHere->getRootInstantiation(); + Symbol* field = ct->getField(sym->name); + isField = true; + sym = field; + } else if (sym->hasFlag(FLAG_TEMP)) { + for_SymbolSymExprs(se, sym) { + if (CallExpr* c = toCallExpr(se->parentExpr)) { + if ((c->isPrimitive(PRIM_SET_MEMBER) || + c->isPrimitive(PRIM_INIT_FIELD)) && se == c->get(3)) { + isField = true; + + // replace 'sym' with the field for the error location + AggregateType* ct = toAggregateType(c->get(1)->getValType()); + ct = ct->getRootInstantiation(); + SymExpr* nameSe = toSymExpr(c->get(2)); + VarSymbol* nameVar = toVarSymbol(nameSe->symbol()); + const char* name = astr(nameVar->immediate->v_string.c_str()); + Symbol* field = ct->getField(name); + sym = field; + break; + } + } + } + } + + return isField; +} + void checkSurprisingGenericDecls(Symbol* sym, Expr* typeExpr, AggregateType* forFieldInHere) { if (sym == nullptr || typeExpr == nullptr) { @@ -13897,40 +13933,22 @@ void checkSurprisingGenericDecls(Symbol* sym, Expr* typeExpr, declType = typeExpr->typeInfo(); } + bool genericWithDefaults = false; + if (AggregateType* at = toAggregateType(declType)) + genericWithDefaults = at->isGenericWithDefaults(); + if (declType->symbol->hasFlag(FLAG_GENERIC) && + declType != dtAny && // workaround for interfaces + !genericWithDefaults && !sym->hasFlag(FLAG_MARKED_GENERIC) && + !sym->hasFlag(FLAG_RET_TYPE_MARKED_GENERIC) && !sym->hasFlag(FLAG_TYPE_VARIABLE)) { // is it a field? check to see if it's a temp within an initializer // initializing field (in which case, we should think about // this as a field). - bool isField = false; - - if (forFieldInHere) { - AggregateType* ct = forFieldInHere->getRootInstantiation(); - Symbol* field = ct->getField(sym->name); - isField = true; - sym = field; - } else if (sym->hasFlag(FLAG_TEMP)) { - for_SymbolSymExprs(se, sym) { - if (CallExpr* c = toCallExpr(se->parentExpr)) { - if ((c->isPrimitive(PRIM_SET_MEMBER) || - c->isPrimitive(PRIM_INIT_FIELD)) && se == c->get(3)) { - isField = true; - - // replace 'sym' with the field for the error location - AggregateType* ct = toAggregateType(c->get(1)->getValType()); - ct = ct->getRootInstantiation(); - SymExpr* nameSe = toSymExpr(c->get(2)); - VarSymbol* nameVar = toVarSymbol(nameSe->symbol()); - const char* name = astr(nameVar->immediate->v_string.c_str()); - Symbol* field = ct->getField(name); - sym = field; - break; - } - } - } - } + // Note: this can change 'sym' to a field rather than a tmp. + bool isField = computeIsField(sym, forFieldInHere); if (isClassLikeOrManaged(declType)) { auto dec = classTypeDecorator(declType); @@ -14031,9 +14049,16 @@ void checkSurprisingGenericDecls(Symbol* sym, Expr* typeExpr, s.append("(?)"); } - const char* fieldOrVar = isField?"field":"variable"; - USR_WARN(sym, "please use '?' when declaring a %s with generic type", - fieldOrVar); + if (isFnSymbol(sym)) { + USR_WARN(sym, "please use '?' when declaring a routine " + "with a generic return type"); + + } else { + const char* fieldOrVar = isField?"field":"variable"; + USR_WARN(sym, + "please use '?' when declaring a %s with generic type", + fieldOrVar); + } USR_PRINT(sym, "for example with '%s'", s.c_str()); } if (fWarnUnstable) { @@ -14041,6 +14066,30 @@ void checkSurprisingGenericDecls(Symbol* sym, Expr* typeExpr, } } } + + // if it was marked generic, but it's not generic (or an instantiation) + // then have a fatal error + if (sym->hasFlag(FLAG_MARKED_GENERIC) || + sym->hasFlag(FLAG_RET_TYPE_MARKED_GENERIC)) { + if (!declType->symbol->hasFlag(FLAG_GENERIC) && + !genericWithDefaults) { + bool isField = computeIsField(sym, forFieldInHere); + + const char* thing = ""; + if (isFnSymbol(sym)) { + thing = astr("return type of the routine ", sym->name); + } else if (isField) { + thing = astr("field ", sym->name); + } else { + thing = astr("variable ", sym->name); + } + + USR_FATAL(sym, + "the %s is marked generic with (?) " + "but the type '%s' is not generic", + thing, toString(declType, /*decorators*/ false)); + } + } } } diff --git a/compiler/resolution/resolveFunction.cpp b/compiler/resolution/resolveFunction.cpp index 607857a00f4c..488eab739155 100644 --- a/compiler/resolution/resolveFunction.cpp +++ b/compiler/resolution/resolveFunction.cpp @@ -455,6 +455,8 @@ void resolveSpecifiedReturnType(FnSymbol* fn) { resolveBlockStmt(fn->retExprType); + checkSurprisingGenericDecls(fn, fn->retExprType->body.tail, nullptr); + retType = fn->retExprType->body.tail->typeInfo(); if (SymExpr* se = toSymExpr(fn->retExprType->body.tail)) { diff --git a/doc/rst/language/spec/iterators.rst b/doc/rst/language/spec/iterators.rst index 0e92df9ae0be..3f79b90fd0b1 100644 --- a/doc/rst/language/spec/iterators.rst +++ b/doc/rst/language/spec/iterators.rst @@ -232,13 +232,13 @@ typically made by iterating over it in a loop. .. BLOCK-test-chapelnoprint - proc Tree.writeThis(x) + override proc Tree.serialize(writer, ref serializer) { var first = true; for node in postorder(this) { if first then first = false; - else x.write(" "); - write(node); + else writer.write(" "); + writer.write(node); } } writeln("Tree Data"); diff --git a/doc/rst/meta/modules/packages.rst b/doc/rst/meta/modules/packages.rst index 7807fa2d3630..7db93649acd4 100644 --- a/doc/rst/meta/modules/packages.rst +++ b/doc/rst/meta/modules/packages.rst @@ -9,6 +9,10 @@ fundamental enough or because they are not yet mature enough for inclusion there. Over time, we expect many of these to become ``mason`` packages. +.. warning:: + + All package modules are currently unstable and may change in the future. + Algorithms ---------- .. toctree:: diff --git a/frontend/include/chpl/parsing/parser-error-classes-list.h b/frontend/include/chpl/parsing/parser-error-classes-list.h index 14f78ef1e3d2..4a3c9c90c334 100644 --- a/frontend/include/chpl/parsing/parser-error-classes-list.h +++ b/frontend/include/chpl/parsing/parser-error-classes-list.h @@ -40,7 +40,7 @@ PARSER_ERROR_CLASS(BisonUnknownError, std::string, std::string) // other parser errors PARSER_SYNTAX_CLASS(CannotAttachPragmas, const uast::AstNode*) PARSER_SYNTAX_CLASS(CommentEOF, Location, Location) -PARSER_SYNTAX_CLASS(ExceptOnlyInvalidExpr, uast::VisibilityClause::LimitationKind) +PARSER_SYNTAX_CLASS(ExceptOnlyInvalidExpr, Location, uast::VisibilityClause::LimitationKind) PARSER_SYNTAX_CLASS(ExternUnclosedPair, std::string) PARSER_SYNTAX_CLASS(InvalidIndexExpr) PARSER_SYNTAX_CLASS(InvalidNewForm, const uast::AstNode*) diff --git a/frontend/include/chpl/uast/PragmaList.h b/frontend/include/chpl/uast/PragmaList.h index 3b255ef3ab29..aff4378c5e82 100644 --- a/frontend/include/chpl/uast/PragmaList.h +++ b/frontend/include/chpl/uast/PragmaList.h @@ -376,6 +376,7 @@ PRAGMA(LOOP_BODY_ARGUMENT_CLASS, npr, "loop body argument class", ncm) PRAGMA(MANAGED_POINTER, ypr, "managed pointer", "e.g. Owned and Shared") PRAGMA(MANAGED_POINTER_NONNILABLE, npr, "managed pointer nonnilable", "e.g. non-nilable Owned and Shared") PRAGMA(MARKED_GENERIC, npr, "marked generic", "marked generic using the type query syntax") +PRAGMA(RET_TYPE_MARKED_GENERIC, npr, "ret type marked generic", "ret type marked generic with (?)") PRAGMA(SUPERCLASS_MARKED_GENERIC, npr, "supreclass marked generic", "superclass is marked generic") PRAGMA(MAYBE_ARRAY_TYPE, npr, "maybe array type", "function may be computing array type") PRAGMA(MAYBE_COPY_ELIDED, npr, "maybe copy elided", "symbol might be dead early due to copy elision") diff --git a/frontend/lib/parsing/ParserContextImpl.h b/frontend/lib/parsing/ParserContextImpl.h index 010f1a685c5a..3ba8980886e8 100644 --- a/frontend/lib/parsing/ParserContextImpl.h +++ b/frontend/lib/parsing/ParserContextImpl.h @@ -2201,8 +2201,9 @@ buildVisibilityClause(YYLTYPE location, owned symbol, if (limitationKind == VisibilityClause::LimitationKind::EXCEPT || limitationKind == VisibilityClause::LimitationKind::ONLY) { if (!asExpr) { + auto limitationLoc = builder->getLocation(expr.get()); error = CHPL_PARSER_REPORT(this, ExceptOnlyInvalidExpr, location, - limitationKind); + limitationLoc, limitationKind); } } else if (limitationKind == VisibilityClause::LimitationKind::BRACES) { CHPL_ASSERT(isImport && "braces should only be used with import statements"); diff --git a/frontend/lib/parsing/lexer-help.h b/frontend/lib/parsing/lexer-help.h index d5c7e3ba5e1d..4198a00c2b6b 100644 --- a/frontend/lib/parsing/lexer-help.h +++ b/frontend/lib/parsing/lexer-help.h @@ -125,21 +125,23 @@ static int processToken(yyscan_t scanner, int t) { static std::string eatStringLiteral(yyscan_t scanner, const char* startChar, + int nColOffset, bool& isErroneousOut); static std::string eatTripleStringLiteral(yyscan_t scanner, const char* startChar, + int nColOffset, bool& isErroneousOut); static int processStringLiteral(yyscan_t scanner, const char* startChar, int type) { - // update the location for the string start (e.g. b" ) + // figure out the location offset for the string start (e.g. b" ) const char* pch = yyget_text(scanner); + int nColOffset = (int) strlen(pch); YYLTYPE* loc = yyget_lloc(scanner); - updateLocation(loc, 0, strlen(pch)); bool erroneous = false; - std::string value = eatStringLiteral(scanner, startChar, erroneous); + std::string value = eatStringLiteral(scanner, startChar, nColOffset, erroneous); ParserContext* context = yyget_extra(scanner); if (context->parseStats) @@ -181,13 +183,13 @@ static int processStringLiteral(yyscan_t scanner, static int processTripleStringLiteral(yyscan_t scanner, const char* startChar, int type) { - // update the location for the string start (e.g. b" ) + // figure out the location offset for the string start (e.g. b" ) const char* pch = yyget_text(scanner); + int nColOffset = (int) strlen(pch); YYLTYPE* loc = yyget_lloc(scanner); - updateLocation(loc, 0, strlen(pch)); bool erroneous = false; - std::string value = eatTripleStringLiteral(scanner, startChar, erroneous); + std::string value = eatTripleStringLiteral(scanner, startChar, nColOffset, erroneous); ParserContext* context = yyget_extra(scanner); if (context->parseStats) @@ -265,12 +267,13 @@ static inline SizedStr makeSizedStr(const char* allocatedData, long size) { static std::string eatStringLiteral(yyscan_t scanner, const char* startChar, + int nColOffset, bool& isErroneousOut) { YYLTYPE* loc = yyget_lloc(scanner); const char startCh = *startChar; int c = 0; int nLines = 0; - int nCols = 0; + int nCols = nColOffset; std::string s; isErroneousOut = false; @@ -386,13 +389,14 @@ static std::string eatStringLiteral(yyscan_t scanner, static std::string eatTripleStringLiteral(yyscan_t scanner, const char* startChar, + int nColOffset, bool& isErroneousOut) { YYLTYPE* loc = yyget_lloc(scanner); const char startCh = *startChar; int startChCount = 0; int c = 0; int nLines = 0; - int nCols = 0; + int nCols = nColOffset; std::string s; isErroneousOut = false; diff --git a/frontend/lib/parsing/parser-error-classes-list.cpp b/frontend/lib/parsing/parser-error-classes-list.cpp index 7239ed2cfe45..35cfc17271cb 100644 --- a/frontend/lib/parsing/parser-error-classes-list.cpp +++ b/frontend/lib/parsing/parser-error-classes-list.cpp @@ -101,12 +101,13 @@ void ErrorCommentEOF::write(ErrorWriterBase& wr) const { } void ErrorExceptOnlyInvalidExpr::write(ErrorWriterBase& wr) const { - auto loc = std::get(info); + auto loc = std::get<0>(info); + auto limitLoc = std::get<1>(info); auto limitationKind = std::get(info); wr.heading(kind_, type_, loc, "incorrect expression in '", limitationKind, "' list, identifier expected."); wr.message("In the '", limitationKind, "' list here:"); - wr.code(loc); + wr.code(loc, { limitLoc }); } void ErrorExternUnclosedPair::write(ErrorWriterBase& wr) const { diff --git a/frontend/lib/parsing/parsing-queries.cpp b/frontend/lib/parsing/parsing-queries.cpp index 477d7d22baf7..1c23a511db7d 100644 --- a/frontend/lib/parsing/parsing-queries.cpp +++ b/frontend/lib/parsing/parsing-queries.cpp @@ -1405,9 +1405,31 @@ static bool isAstDeprecated(Context* context, const AstNode* ast) { return attr && attr->isDeprecated(); } +static bool isUnstablePackageModule(Context* context, const ID& id) { + auto node = parsing::idToAst(context, id); + if (!node) return false; + + // If the node is deprecated, no unstable warning is needed + if (isAstDeprecated(context, node)) return false; + + bool isPackageModule = false; + if (node->isModule()) { + UniqueString path; + if (context->filePathForId(id, path)) { + path = context->adjustPathForErrorMsg(path); + isPackageModule = path.startsWith("$CHPL_HOME/modules/packages/"); + } + } + + // Some package modules may be stable, those exceptions should be encoded here + + return isPackageModule; +} + static bool isIdUnstable(Context* context, const ID& id) { auto attr = parsing::idToAttributeGroup(context, id); - return attr && ( attr->isUnstable() || attr->hasPragma(PRAGMA_UNSTABLE) ); + return (attr && ( attr->isUnstable() || attr->hasPragma(PRAGMA_UNSTABLE) )) + || isUnstablePackageModule(context, id); } bool @@ -1566,7 +1588,7 @@ unstableWarningForIdImpl(Context* context, ID idMention, ID idTarget) { if (!targetNamedDecl) return false; auto attributes = parsing::idToAttributeGroup(context, idTarget); - auto storedMsg = attributes->unstableMessage(); + auto storedMsg = attributes ? attributes->unstableMessage() : UniqueString(); std::string msg = storedMsg.isEmpty() ? createDefaultUnstableMessage(context, targetNamedDecl) : storedMsg.c_str(); diff --git a/modules/dists/BlockCycDist.chpl b/modules/dists/BlockCycDist.chpl index 1da1c1189262..757e6e54f2bc 100644 --- a/modules/dists/BlockCycDist.chpl +++ b/modules/dists/BlockCycDist.chpl @@ -18,6 +18,8 @@ * limitations under the License. */ +@unstable("BlockCycDist is unstable and may change in the future") +prototype module BlockCycDist { // // BlockCyclic Distribution // @@ -327,6 +329,9 @@ proc BlockCyclic.writeThis(x) throws { for locid in targetLocDom do x.writeln(" [", locid, "] ", locDist(locid)); } +override proc BlockCyclic.serialize(writer, ref serializer) throws { + writeThis(writer); +} // // convert an index into a locale value @@ -490,6 +495,9 @@ proc LocBlockCyclic.writeThis(x) throws { } x.write("locale ", localeid, " owns blocks: ", myStarts); } +override proc LocBlockCyclic.serialize(writer, ref serializer) throws { + writeThis(writer); +} //////////////////////////////////////////////////////////////////////////////// // BlockCyclic Domain Class @@ -781,6 +789,9 @@ proc LocBlockCyclicDom.computeFlatInds() { proc LocBlockCyclicDom.writeThis(x) throws { x.write(myStarts); } +override proc LocBlockCyclicDom.serialize(writer, ref serializer) throws { + writeThis(writer); +} proc LocBlockCyclicDom.enumerateBlocks() { for i in myStarts { @@ -1202,6 +1213,9 @@ class LocBlockCyclicArr { override proc writeThis(f) throws { halt("LocBlockCyclicArr.writeThis() is not implemented / should not be needed"); } + override proc serialize(writer, ref serializer) throws { + halt("LocBlockCyclicArr.serialize() is not implemented / should not be needed"); + } } @@ -1298,3 +1312,4 @@ proc _computeBlockCyclic(waylo, numelems, lo, wayhi, numblocks, blocknum) { return (blo, bhi); } +} // BlockCycDist diff --git a/modules/dists/BlockDist.chpl b/modules/dists/BlockDist.chpl index 719bbe37122b..5063646a68ab 100644 --- a/modules/dists/BlockDist.chpl +++ b/modules/dists/BlockDist.chpl @@ -221,10 +221,7 @@ By default, parallelism within each locale is applied to that locale's block of indices by creating a task for each available processor core (or the number of local indices if it is less than the number of cores). The local domain indices are then statically divided as evenly -as possible between those tasks. This default can be modified by -changing the values of ``dataParTasksPerLocale``, -``dataParIgnoreRunningTasks``, and ``dataParMinGranularity`` in the -``blockDist``'s initializer: +as possible between those tasks. **Initializer Arguments** @@ -235,13 +232,7 @@ The ``blockDist`` initializer is defined as follows: proc blockDist.init( boundingBox: domain(?), - targetLocales: [] locale = Locales, - dataParTasksPerLocale = // value of dataParTasksPerLocale config const, - dataParIgnoreRunningTasks = // value of dataParIgnoreRunningTasks config const, - dataParMinGranularity = // value of dataParMinGranularity config const, - param rank = boundingBox.rank, - type idxType = boundingBox.idxType, - type sparseLayoutType = unmanaged DefaultDist) + targetLocales: [] locale = Locales) The arguments ``boundingBox`` (a domain) and ``targetLocales`` (an array) define the mapping of any index of ``idxType`` type to a locale @@ -253,25 +244,6 @@ heuristic is used to reshape the array of target locales so that it matches the rank of the distribution and each dimension contains an approximately equal number of indices. -The arguments ``dataParTasksPerLocale``, -``dataParIgnoreRunningTasks``, and ``dataParMinGranularity`` set the -knobs that are used to control intra-locale data parallelism for -block-distributed domains and arrays in the same way that the -like-named config constants control data parallelism for ranges and -default-distributed domains and arrays. - -The ``rank`` and ``idxType`` arguments are inferred from the -``boundingBox`` argument unless explicitly set. They must match the -rank and index type of the domains distributed using the ``blockDist`` -instance. If the ``boundingBox`` argument is a stridable domain, the -stride information will be ignored and the ``boundingBox`` will only -use the low and high bounds. - -When a ``sparse subdomain`` is created for a ``blockDist`` distributed -domain, the ``sparseLayoutType`` will be the layout of these sparse -domains. The default currently uses coordinate storage, but -:class:`LayoutCS.CS` is an interesting alternative. - **Convenience Factory Methods** It is common for a ``blockDist``-distributed domain or array to be @@ -409,6 +381,8 @@ record blockDist { forwarding const chpl_distHelp: chpl_PrivatizedDistHelper(unmanaged BlockImpl(rank, idxType, _to_unmanaged(sparseLayoutType))); + pragma "last resort" + @unstable("passing arguments other than 'boundingBox' and 'targetLocales' to 'blockDist' is currently unstable") proc init(boundingBox: domain, targetLocales: [] locale = Locales, dataParTasksPerLocale=getDataParTasksPerLocale(), @@ -432,6 +406,16 @@ record blockDist { value); } + proc init(boundingBox: domain, + targetLocales: [] locale = Locales) + { + this.init(boundingBox, targetLocales, + /* by specifying even one unstable argument, this should select + the whole unstable constructor, which has defaults for everything + else. */ + dataParTasksPerLocale=getDataParTasksPerLocale()); + } + proc init(_pid : int, _instance, _unowned : bool) { this.rank = _instance.rank; this.idxType = _instance.idxType; @@ -478,6 +462,10 @@ record blockDist { proc writeThis(x) { chpl_distHelp.writeThis(x); } + + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } @@ -642,6 +630,10 @@ class LocBlockArr { halt("LocBlockArr.writeThis() is not implemented / should not be needed"); } + override proc serialize(writer, ref serializer) throws { + halt("LocBlockArr.serialize() is not implemented / should not be needed"); + } + proc deinit() { // Elements in myElems are deinited in dsiDestroyArr if necessary. // Here we need to clean up the rest of the array. @@ -868,6 +860,10 @@ proc BlockImpl.writeThis(x) throws { " owns chunk: ", locDist(locid).myChunk); } +override proc BlockImpl.serialize(writer, ref serializer) throws { + writeThis(writer); +} + proc BlockImpl.dsiIndexToLocale(ind: idxType) where rank == 1 { return targetLocales(targetLocsIdx(ind)); } @@ -2172,6 +2168,7 @@ class BoxedSync { // guard against dynamic dispatch trying to resolve write()ing the sync override proc writeThis(f) throws { } + override proc serialize(writer, ref serializer) throws { } } proc BlockArr.doiScan(op, dom) where (rank == 1) && diff --git a/modules/dists/CyclicDist.chpl b/modules/dists/CyclicDist.chpl index 79b3df2dd773..f997d571ef08 100644 --- a/modules/dists/CyclicDist.chpl +++ b/modules/dists/CyclicDist.chpl @@ -129,11 +129,7 @@ By default, parallelism within each locale is applied to that locale's local, strided block of indices by creating a task for each available processor core (or the number of local indices if it is less than the number of cores). The local domain indices are then statically divided -as evenly as possible between those tasks. This default can be -modified by changing the values of ``dataParTasksPerLocale``, -``dataParIgnoreRunningTasks``, and ``dataParMinGranularity`` in the -``cyclicDist``'s initializer: - +as evenly as possible between those tasks. **Initializer Arguments** @@ -143,12 +139,7 @@ The ``cyclicDist`` initializer is defined as follows: proc cyclicDist.init( startIdx, - targetLocales: [] locale = Locales, - dataParTasksPerLocale = // value of dataParTasksPerLocale config const, - dataParIgnoreRunningTasks = // value of dataParIgnoreRunningTasks config const, - dataParMinGranularity = // value of dataParMinGranularity config const, - param rank: int = // inferred from startIdx argument, - type idxType = // inferred from startIdx argument ) + targetLocales: [] locale = Locales) The argument ``startIdx`` is a tuple of integers defining an index that will be distributed to the first locale in ``targetLocales``. @@ -163,18 +154,6 @@ heuristic is used to reshape the array of target locales so that it matches the rank of the distribution and each dimension contains an approximately equal number of indices. -The arguments ``dataParTasksPerLocale``, ``dataParIgnoreRunningTasks``, -and ``dataParMinGranularity`` set the knobs that are used to -control intra-locale data parallelism for cyclic-distributed domains -and arrays in the same way that the like-named config constants -control data parallelism for ranges and default-distributed domains -and arrays. - -The ``rank`` and ``idxType`` arguments are inferred from the -``startIdx`` argument unless explicitly set. -They must match the rank and index type of the domains -"dmapped" using that Cyclic instance. - **Convenience Factory Methods** It is common for a ``cyclicDist``-distributed domain or array to use @@ -261,6 +240,8 @@ record cyclicDist { forwarding const chpl_distHelp: chpl_PrivatizedDistHelper(unmanaged CyclicImpl(rank, idxType)); + pragma "last resort" + @unstable("passing arguments other than 'boundingBox' and 'targetLocales' to 'cyclicDist' is currently unstable") proc init(startIdx, targetLocales: [] locale = Locales, dataParTasksPerLocale=getDataParTasksPerLocale(), @@ -286,6 +267,17 @@ record cyclicDist { value); } + proc init(startIdx, + targetLocales: [] locale = Locales) + where isTuple(startIdx) || isIntegral(startIdx) + { + this.init(startIdx, targetLocales, + /* by specifying even one unstable argument, this should select + the whole unstable constructor, which has defaults for everything + else. */ + dataParTasksPerLocale=getDataParTasksPerLocale()); + } + proc init(_pid : int, _instance, _unowned : bool) { this.rank = _instance.rank; this.idxType = _instance.idxType; @@ -332,6 +324,9 @@ record cyclicDist { proc writeThis(x) { chpl_distHelp.writeThis(x); } + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } @@ -581,6 +576,9 @@ proc CyclicImpl.writeThis(x) throws { x.writeln(" [", locid, "=", targetLocs(locid), "] owns chunk: ", locDist(locid).myChunk); } +override proc CyclicImpl.serialize(writer, ref serializer) throws { + writeThis(writer); +} proc CyclicImpl.targetLocsIdx(i: idxType) { const numLocs:idxType = targetLocDom.sizeAs(idxType); @@ -1273,6 +1271,9 @@ class LocCyclicArr { override proc writeThis(f) throws { halt("LocCyclicArr.writeThis() is not implemented / should not be needed"); } + override proc serialize(writer, ref serializer) throws { + halt("LocCyclicArr.serialize() is not implemented / should not be needed"); + } } proc LocCyclicArr.this(i) ref { diff --git a/modules/dists/DimensionalDist2D.chpl b/modules/dists/DimensionalDist2D.chpl index 5bcae231d28e..b92bf7e8ab3b 100644 --- a/modules/dists/DimensionalDist2D.chpl +++ b/modules/dists/DimensionalDist2D.chpl @@ -27,6 +27,9 @@ // * Ensure that reallocation works with block-cyclic 1-d distribution // when the domain's stride changes. +@unstable("DimensionalDist2D is unstable and may change in the future") +prototype module DimensionalDist2D { + use DSIUtil; //use WrapperDist; @@ -397,6 +400,9 @@ class LocDimensionalArr { override proc writeThis(f) throws { halt("LocDimensionalArr.writeThis() is not implemented / should not be needed"); } + override proc serialize(writer, ref serializer) throws { + halt("LocDimensionalArr.serialize() is not implemented / should not be needed"); + } } @@ -1445,3 +1451,5 @@ iter DimensionalArr._dsiIteratorHelper(alDom, (f1, f2)) ref { yield lastLocAdesc!.myStorageArr(i1, i2); } } + +} // DimensionalDist2D diff --git a/modules/dists/HashedDist.chpl b/modules/dists/HashedDist.chpl index d9eb503d33d9..cec98317d0ad 100644 --- a/modules/dists/HashedDist.chpl +++ b/modules/dists/HashedDist.chpl @@ -18,6 +18,8 @@ * limitations under the License. */ +@unstable("HashedDist is unstable and may change in the future") +prototype module HashedDist { config param debugUserMapAssoc = false; @@ -246,6 +248,10 @@ class Hashed : BaseDist { // x.writeln(" [", locid, "] ", locDist(locid)); } + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + // // convert an index into a locale value // @@ -653,6 +659,10 @@ class LocUserMapAssocDom { x.write(myInds); } + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + // INTERNAL INTERFACE: @@ -1056,6 +1066,10 @@ class LocUserMapAssocArr { x.write(myElems); } + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + // // query for the number of local array elements // @@ -1072,3 +1086,5 @@ class LocUserMapAssocArr { return locDom.myInds.dim(1).boundsCheck(x.dim(1)); } } + +} // HashedDist diff --git a/modules/dists/PrivateDist.chpl b/modules/dists/PrivateDist.chpl index d1622c064b93..ff803455bea4 100644 --- a/modules/dists/PrivateDist.chpl +++ b/modules/dists/PrivateDist.chpl @@ -18,6 +18,9 @@ * limitations under the License. */ +@unstable("PrivateDist is unstable and may change in the future") +prototype module PrivateDist { + use ChplConfig only compiledForSingleLocale; // @@ -85,6 +88,10 @@ class Private: BaseDist { x.writeln("Private Distribution"); } + override proc serialize(writer, ref serializer) throws { + writer.writeln("Private Distribution"); + } + // acts like a singleton proc dsiClone() do return _to_unmanaged(this); @@ -357,3 +364,5 @@ record chpl_privateDistCleanupWrapper { proc deinit() { chpl_privateCW.val = chpl_privateDist; } + +} // PrivateDist diff --git a/modules/dists/ReplicatedDist.chpl b/modules/dists/ReplicatedDist.chpl index 6661b8c81688..5925d6e3523d 100644 --- a/modules/dists/ReplicatedDist.chpl +++ b/modules/dists/ReplicatedDist.chpl @@ -32,6 +32,9 @@ // - support other kinds of domains // - allow run-time change in locales +@unstable("ReplicatedDist is unstable and may change in the future") +prototype module ReplicatedDist { + use DSIUtil; // trace certain DSI methods as they are being invoked @@ -153,20 +156,26 @@ record replicatedDist { } @chpldoc.nodoc - inline operator ==(d1: replicatedDist(?), d2: replicatedDist(?)) { + inline operator ==(d1: replicatedDist, d2: replicatedDist) { if (d1._value == d2._value) then return true; return d1._value.dsiEqualDMaps(d2._value); } @chpldoc.nodoc - inline operator !=(d1: replicatedDist(?), d2: replicatedDist(?)) { + inline operator !=(d1: replicatedDist, d2: replicatedDist) { return !(d1 == d2); } + @chpldoc.nodoc proc writeThis(x) { chpl_distHelp.writeThis(x); } + + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } @@ -200,7 +209,7 @@ proc ReplicatedImpl.init(targetLocales: [] locale = Locales, writeln("ReplicatedImpl initializer over ", targetLocales); } -proc ReplicatedImpl.dsiEqualDMaps(that: ReplicatedImpl(?)) { +proc ReplicatedImpl.dsiEqualDMaps(that: ReplicatedImpl) { return this.targetLocales.equals(that.targetLocales); } @@ -548,6 +557,11 @@ class LocReplicatedArr { override proc writeThis(f) throws { halt("LocReplicatedArr.writeThis() is not implemented / should not be needed"); } + + @chpldoc.nodoc + override proc serialize(writer, ref serializer) throws { + halt("LocReplicatedArr.serialize() is not implemented / should not be needed"); + } } @@ -770,3 +784,5 @@ proc ReplicatedArr.dsiLocalSubdomain(loc: locale) { proc ReplicatedArr.dsiLocalSlice(ranges) { return chpl_myLocArr().arrLocalRep((...ranges)); } + +} // ReplicatedDist diff --git a/modules/dists/SparseBlockDist.chpl b/modules/dists/SparseBlockDist.chpl index fc28dcdc0c5d..d989318a6fda 100644 --- a/modules/dists/SparseBlockDist.chpl +++ b/modules/dists/SparseBlockDist.chpl @@ -601,6 +601,10 @@ class LocSparseBlockArr { override proc writeThis(f) throws { halt("LocSparseBlockArr.writeThis() is not implemented / should not be needed"); } + + override proc serialize(writer, ref serializer) throws { + halt("LocSparseBlockArr.serialize() is not implemented / should not be needed"); + } } proc SparseBlockDom.dsiGetDist() { diff --git a/modules/dists/StencilDist.chpl b/modules/dists/StencilDist.chpl index aa3036a7abf0..3d348fdcd0d8 100644 --- a/modules/dists/StencilDist.chpl +++ b/modules/dists/StencilDist.chpl @@ -33,6 +33,9 @@ // mapped to by the distribution. // +@unstable("StencilDist is unstable and may change in the future") +prototype module StencilDist { + private use BlockDist; private use DSIUtil; private use ChapelUtil; @@ -404,6 +407,10 @@ record stencilDist { proc writeThis(x) { chpl_distHelp.writeThis(x); } + + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } @@ -603,6 +610,9 @@ class LocStencilArr { override proc writeThis(f) throws { halt("LocStencilArr.writeThis() is not implemented / should not be needed"); } + override proc serialize(writer, ref serializer) throws { + halt("LocStencilArr.serialize() is not implemented / should not be needed"); + } } private proc makeZero(param rank : int, type idxType) { @@ -783,6 +793,9 @@ proc StencilImpl.writeThis(x) throws { x.writeln(" [", locid, "] locale ", locDist(locid).locale.id, " owns chunk: ", locDist(locid).myChunk); } +override proc StencilImpl.serialize(writer, ref serializer) throws { + writeThis(writer); +} proc StencilImpl.dsiIndexToLocale(ind: idxType) where rank == 1 { return targetLocales(targetLocsIdx(ind)); @@ -2504,3 +2517,5 @@ proc StencilArr.doiOptimizedSwap(other) where debugOptimizedSwap { writeln("StencilArr doing unoptimized swap. Type mismatch"); return false; } + +} // StencilDist diff --git a/modules/internal/Atomics.chpl b/modules/internal/Atomics.chpl index dd58e4960001..2ea394f0492a 100644 --- a/modules/internal/Atomics.chpl +++ b/modules/internal/Atomics.chpl @@ -416,6 +416,10 @@ module Atomics { x.write(read()); } + proc const serialize(writer, ref serializer) throws { + writer.write(read()); + } + } // TODO: should this be an operator method AtomicBool.: ? @@ -756,6 +760,10 @@ module Atomics { x.write(read()); } + proc const serialize(writer, ref serializer) throws { + writer.write(read()); + } + } // TODO: should this be an operator method AtomicT.: ? diff --git a/modules/internal/Bytes.chpl b/modules/internal/Bytes.chpl index 2c89a1ff7c41..d09fda88675d 100644 --- a/modules/internal/Bytes.chpl +++ b/modules/internal/Bytes.chpl @@ -473,6 +473,9 @@ module Bytes { proc readThis(f) throws { compilerError("not implemented: readThis"); } + proc ref deserialize(reader, ref deserialize) throws { + compilerError("not implemented: deserialize"); + } proc init=(b: bytes) { init this; diff --git a/modules/internal/ChapelArray.chpl b/modules/internal/ChapelArray.chpl index 621b4595665a..7402ff7107f5 100644 --- a/modules/internal/ChapelArray.chpl +++ b/modules/internal/ChapelArray.chpl @@ -856,6 +856,11 @@ module ChapelArray { f.read(_value); } + @chpldoc.nodoc + proc ref deserialize(reader, ref deserializer) throws { + readThis(reader); + } + // TODO: Can't this be an initializer? @chpldoc.nodoc proc type deserializeFrom(reader, ref deserializer) throws { @@ -1472,6 +1477,18 @@ module ChapelArray { return chpl__localSliceDefaultArithArrHelp(d); } + @unstable("tryCopy() is subject to change in the future.") + proc tryCopy() throws { + use Reflection; + if !(__primitive("resolves", this.domain. + tryCreateArray(this.eltType))) then + compilerError("cannot call 'tryCopy' on arrays that do not" + + " support a 'tryCreateArray' method."); + var res = this.domain.tryCreateArray(this.eltType); + res = this; + return res; + } + pragma "no copy return" proc chpl__localSliceDefaultArithArrHelp(d: domain) { if (_value.locale != here) then diff --git a/modules/internal/ChapelBase.chpl b/modules/internal/ChapelBase.chpl index 202bdf23f4da..c620286bc5cd 100644 --- a/modules/internal/ChapelBase.chpl +++ b/modules/internal/ChapelBase.chpl @@ -3319,6 +3319,9 @@ module ChapelBase { halt("Module name is not valid string!"); } } + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } var chpl_moduleDeinitFuns = nil: unmanaged chpl_ModuleDeinit?; diff --git a/modules/internal/ChapelDomain.chpl b/modules/internal/ChapelDomain.chpl index 65f5b3bff5db..480403ca31a2 100644 --- a/modules/internal/ChapelDomain.chpl +++ b/modules/internal/ChapelDomain.chpl @@ -1566,6 +1566,59 @@ module ChapelDomain { return _newArray(x); } + pragma "no copy return" + @unstable("tryCreateArray() is subject to change in the future.") + proc tryCreateArray(type eltType, initExpr: ?t) throws + where isSubtype(t, _iteratorRecord) || isCoercible(t, eltType) { + if !(__primitive("resolves", _value.doiTryCreateArray(eltType))) then + compilerError("cannot call 'tryCreateArray' on domains that do not" + + " support a 'doiTryCreateArray' method."); + + chpl_checkEltType(eltType); + chpl_checkNegativeStride(); + + var x = _value.doiTryCreateArray(eltType); + pragma "dont disable remote value forwarding" + proc help() { + _value.add_arr(x); + } + help(); + + chpl_incRefCountsForDomainsInArrayEltTypes(x, x.eltType); + var res = _newArray(x); + res = initExpr; + + return res; + } + + pragma "no copy return" + @unstable("tryCreateArray() is subject to change in the future.") + proc tryCreateArray(type eltType, initExpr: [?dom] ?arrayEltType) throws + where this.rank == dom.rank && isCoercible(arrayEltType, eltType) { + if !(__primitive("resolves", _value.doiTryCreateArray(eltType))) then + compilerError("cannot call 'tryCreateArray' on domains that do not" + + " support a 'doiTryCreateArray' method."); + if boundsChecking then + for (d, ad, i) in zip(this.dims(), dom.dims(), 0..) do + if d.size != ad.size then halt("Domain size mismatch in 'tryCreateArray' dimension " + i:string); + + chpl_checkEltType(eltType); + chpl_checkNegativeStride(); + + var x = _value.doiTryCreateArray(eltType); + pragma "dont disable remote value forwarding" + proc help() { + _value.add_arr(x); + } + help(); + + chpl_incRefCountsForDomainsInArrayEltTypes(x, x.eltType); + var res = _newArray(x); + res = initExpr; + + return res; + } + // assumes that data is already initialized pragma "no copy return" @chpldoc.nodoc @@ -2616,6 +2669,11 @@ module ChapelDomain { _value.dsiSerialRead(f); } + @chpldoc.nodoc + proc ref deserialize(reader, ref deserializer) throws { + readThis(reader); + } + // TODO: Can we convert this to an initializer despite the potential issues // with runtime types? @chpldoc.nodoc diff --git a/modules/internal/ChapelRange.chpl b/modules/internal/ChapelRange.chpl index daa2fb418978..fc0097ef5e74 100644 --- a/modules/internal/ChapelRange.chpl +++ b/modules/internal/ChapelRange.chpl @@ -42,6 +42,15 @@ module ChapelRange { whereas the new rule reverses such direction. */ config param newSliceRule = false; + /* Compile with ``-snewRangeLiteralType`` to switch to using the new rule + for determining the idxType of a range literal with param integral bounds + and to turn off the deprecation warning for using the old rule. + + The new rule defines such idxType to be the type produced by adding + the two bounds. I.e.,``(low..high).idxType`` is ``(low+high).type`` + when ``low`` and ``high`` are integral params. */ + config param newRangeLiteralType = false; + private param unalignedMark = -1; // This enum is documented directly in the spec to fit the presentation flow. @@ -395,10 +404,40 @@ module ChapelRange { // Range builders: used by the parser to create literal ranges // + private + proc computeParamRangeIndexType_Old(param low, param high) type { + // if either type is int, and the int value fits in the other type, + // return the other type + if low.type == int && + min(high.type) <= low && low <= max(high.type) { + return high.type; + } else if high.type == int && + min(low.type) <= high && high <= max(low.type) { + return low.type; + } else { + // otherwise, use the type that '+' would produce. + return (low+high).type; + } + } private proc computeParamRangeIndexType(param low, param high) type { + if newRangeLiteralType { // The idxType of 'low..high' is the type that '+' would produce. return (low+high).type; + } + type newRule = (low+high).type; + type oldRule = computeParamRangeIndexType_Old(low, high); + if newRule == oldRule then + return newRule; + compilerWarning("the idxType of this range literal ", + low:string, "..", high:string, + " with the low bound of the type ", low.type:string, + " and the high bound of the type ", high.type:string, + " is currently ", oldRule:string, + ". In a future release it will be switched to ", newRule:string, + ". To switch to this new typing and turn off this warning,", + " compile with -snewRangeLiteralType."); + return oldRule; } private proc isValidRangeIdxType(type t) param { return isIntegralType(t) || isEnumType(t) || isBoolType(t); diff --git a/modules/internal/ChapelSyncvar.chpl b/modules/internal/ChapelSyncvar.chpl index 2f92626f4950..7911d661e4bf 100644 --- a/modules/internal/ChapelSyncvar.chpl +++ b/modules/internal/ChapelSyncvar.chpl @@ -189,6 +189,10 @@ module ChapelSyncvar { compilerError("sync variables cannot currently be read - use writeEF/writeFF instead"); } + proc deserialize(reader, ref deserializer) throws { + compilerError("sync variables cannot currently be read - use writeEF/writeFF instead"); + } + @chpldoc.nodoc proc type deserializeFrom(reader, ref deserializer) throws { var ret : this; @@ -200,6 +204,10 @@ module ChapelSyncvar { proc writeThis(x) throws { compilerError("sync variables cannot currently be written - apply readFE/readFF() to those variables first"); } + + proc serialize(writer, ref serializer) throws { + compilerError("sync variables cannot currently be written - apply readFE/readFF() to those variables first"); + } } /* @@ -869,6 +877,10 @@ module ChapelSyncvar { compilerError("single variables cannot currently be read - use writeEF instead"); } + proc deserialize(reader, ref deserializer) throws { + compilerError("single variables cannot currently be read - use writeEF instead"); + } + @chpldoc.nodoc proc type deserializeFrom(reader, ref deserializer) throws { var ret : this; @@ -880,6 +892,10 @@ module ChapelSyncvar { proc writeThis(x) throws { compilerError("single variables cannot currently be written - apply readFF() to those variables first"); } + + proc serialize(writer, ref serializer) throws { + compilerError("single variables cannot currently be written - apply readFF() to those variables first"); + } } /* Read a full ``single`` variable, leaving it full. diff --git a/modules/internal/DefaultRectangular.chpl b/modules/internal/DefaultRectangular.chpl index 7eb98919b1e7..e2e7519a8318 100644 --- a/modules/internal/DefaultRectangular.chpl +++ b/modules/internal/DefaultRectangular.chpl @@ -96,6 +96,7 @@ module DefaultRectangular { return ret; } + @unstable("DefaultDist is unstable and may change in the future") class DefaultDist: BaseDist { override proc dsiNewRectangularDom(param rank: int, type idxType, param strides: strideKind, inds) { diff --git a/modules/internal/NetworkAtomics.chpl b/modules/internal/NetworkAtomics.chpl index ec73535b46c2..04d2d9007be6 100644 --- a/modules/internal/NetworkAtomics.chpl +++ b/modules/internal/NetworkAtomics.chpl @@ -136,6 +136,10 @@ module NetworkAtomics { x.write(read()); } + proc const serialize(writer, ref serializer) throws { + writer.write(read()); + } + } operator :(rhs: bool, type t:RAtomicBool) { @@ -337,6 +341,10 @@ module NetworkAtomics { x.write(read()); } + proc const serialize(writer, ref serializer) throws { + writer.write(read()); + } + } operator :(rhs, type t:RAtomicT) diff --git a/modules/internal/OwnedObject.chpl b/modules/internal/OwnedObject.chpl index fd7bab0a4cac..f4894e2e5e37 100644 --- a/modules/internal/OwnedObject.chpl +++ b/modules/internal/OwnedObject.chpl @@ -389,6 +389,11 @@ module OwnedObject { _readWriteHelper(f); } + @chpldoc.nodoc + proc _owned.serialize(writer, ref serializer) throws { + _readWriteHelper(writer); + } + // Don't print out 'chpl_p' when printing an _owned, just print class pointer @chpldoc.nodoc proc _owned._readWriteHelper(f) throws { diff --git a/modules/internal/SharedObject.chpl b/modules/internal/SharedObject.chpl index d5e2bfbd067e..70a453e63bf0 100644 --- a/modules/internal/SharedObject.chpl +++ b/modules/internal/SharedObject.chpl @@ -551,11 +551,19 @@ module SharedObject { _readWriteHelper(f); } + proc ref _shared.deserialize(reader, ref deserializer) throws { + _readWriteHelper(reader); + } + @chpldoc.nodoc proc _shared.writeThis(f) throws { _readWriteHelper(f); } + proc _shared.serialize(writer, ref serializer) throws { + _readWriteHelper(writer); + } + // Don't print out 'chpl_p' when printing an Shared, just print class pointer @chpldoc.nodoc proc _shared._readWriteHelper(f) throws { @@ -1031,4 +1039,8 @@ module WeakPointer { } } + proc weak.serialize(writer, ref serializer) throws { + writeThis(writer); + } + } diff --git a/modules/internal/String.chpl b/modules/internal/String.chpl index 0ca7e5aef2a3..db62e46d1d26 100644 --- a/modules/internal/String.chpl +++ b/modules/internal/String.chpl @@ -90,6 +90,9 @@ module String { proc writeThis(f) throws { f.write(_bindex); } + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } operator :(val: byteIndex, type t:string) { return val._bindex: string; @@ -114,6 +117,10 @@ module String { f.write(_cpindex); } + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + operator :(val: codepointIndex, type t:string) { return val._cpindex: string; } diff --git a/modules/internal/localeModels/apu/LocaleModel.chpl b/modules/internal/localeModels/apu/LocaleModel.chpl index 0cb2178a73d7..e4f1ba7fd480 100644 --- a/modules/internal/localeModels/apu/LocaleModel.chpl +++ b/modules/internal/localeModels/apu/LocaleModel.chpl @@ -76,6 +76,10 @@ module LocaleModel { f.write('.'+name_); } + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + override proc _getChildCount(): int { return 0; } iter getChildIndices() : int { diff --git a/modules/internal/localeModels/flat/LocaleModel.chpl b/modules/internal/localeModels/flat/LocaleModel.chpl index b36bbad5757d..929d8510152d 100644 --- a/modules/internal/localeModels/flat/LocaleModel.chpl +++ b/modules/internal/localeModels/flat/LocaleModel.chpl @@ -175,6 +175,10 @@ module LocaleModel { f.write(name); } + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + override proc _getChildCount() do return this.myLocaleSpace.size; proc getChildSpace() do return this.myLocaleSpace; diff --git a/modules/internal/localeModels/gpu/LocaleModel.chpl b/modules/internal/localeModels/gpu/LocaleModel.chpl index c8ca6759b9b1..a5cbc142fedb 100644 --- a/modules/internal/localeModels/gpu/LocaleModel.chpl +++ b/modules/internal/localeModels/gpu/LocaleModel.chpl @@ -244,6 +244,10 @@ module LocaleModel { f.write("-GPU" + sid:string); } + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + override proc _getChildCount(): int { return 0; } iter getChildIndices() : int { @@ -409,6 +413,10 @@ module LocaleModel { f.write(name); } + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + override proc _getChildCount() do return this.myLocaleSpace.size; proc getChildSpace() do return this.myLocaleSpace; diff --git a/modules/internal/localeModels/numa/LocaleModel.chpl b/modules/internal/localeModels/numa/LocaleModel.chpl index cca04d175e55..ba14393c2827 100644 --- a/modules/internal/localeModels/numa/LocaleModel.chpl +++ b/modules/internal/localeModels/numa/LocaleModel.chpl @@ -86,6 +86,10 @@ module LocaleModel { f.write('.'+ndName); } + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + override proc _getChildCount(): int { return 0; } iter getChildIndices() : int { halt("No children to iterate over."); @@ -258,6 +262,10 @@ module LocaleModel { f.write(name); } + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + override proc _getChildCount() return this.myLocaleSpace.size; proc getChildSpace() return this.myLocaleSpace; diff --git a/modules/layouts/LayoutCS.chpl b/modules/layouts/LayoutCS.chpl index 9a43cdef0493..a41d288320e5 100644 --- a/modules/layouts/LayoutCS.chpl +++ b/modules/layouts/LayoutCS.chpl @@ -18,6 +18,9 @@ * limitations under the License. */ +@unstable("LayoutCS is unstable and may change in the future") +prototype module LayoutCS { + import RangeChunk; @chpldoc.nodoc @@ -747,3 +750,5 @@ class CSArr: BaseSparseArrImpl(?) { } } } // CSArr + +} // LayoutCS diff --git a/modules/packages/AtomicObjects.chpl b/modules/packages/AtomicObjects.chpl index 91d96f97876b..93d6415e5f21 100644 --- a/modules/packages/AtomicObjects.chpl +++ b/modules/packages/AtomicObjects.chpl @@ -394,6 +394,10 @@ prototype module AtomicObjects { proc readThis(f) throws { compilerWarning("Reading an ABA is not supported"); } + @chpldoc.nodoc + proc deserialize(reader, ref deserializer) throws { + compilerWarning("Reading an ABA is not supported"); + } @chpldoc.nodoc proc init(type __ABA_objType, reader: fileReader, ref deserializer) { @@ -405,6 +409,10 @@ prototype module AtomicObjects { proc writeThis(f) throws { f.write("(ABA){cnt=", this.__ABA_cnt, ", obj=", this.getObject(), "}"); } + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } forwarding this.getObject()!; } @@ -653,6 +661,10 @@ prototype module AtomicObjects { proc readThis(f) throws { compilerWarning("Reading an AtomicObject is not supported"); } + @chpldoc.nodoc + proc deserialize(reader, ref deserializer) throws { + compilerWarning("Reading an AtomicObject is not supported"); + } @chpldoc.nodoc proc init(type objType, @@ -667,5 +679,9 @@ prototype module AtomicObjects { proc writeThis(f) throws { f.write(atomicVariable.read()); } + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } } diff --git a/modules/packages/DistributedBag.chpl b/modules/packages/DistributedBag.chpl index 6b5c83698742..2481dcffddca 100644 --- a/modules/packages/DistributedBag.chpl +++ b/modules/packages/DistributedBag.chpl @@ -260,6 +260,10 @@ module DistributedBag { proc readThis(f) throws { compilerError("Reading a DistBag is not supported"); } + @chpldoc.nodoc + proc deserialize(reader, ref deserializer) throws { + compilerError("Reading a DistBag is not supported"); + } @chpldoc.nodoc proc init(type eltType, reader: fileReader, ref deserializer) { @@ -277,6 +281,10 @@ module DistributedBag { } ch.write("]"); } + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } forwarding _value; } diff --git a/modules/packages/EpochManager.chpl b/modules/packages/EpochManager.chpl index 66e5a4aba8b4..654efc3a88c5 100644 --- a/modules/packages/EpochManager.chpl +++ b/modules/packages/EpochManager.chpl @@ -516,6 +516,10 @@ module EpochManager { proc readThis(f) throws { compilerError("Reading a Vector is not supported"); } + @chpldoc.nodoc + proc deserialize(reader, ref deserializer) throws { + compilerError("Reading a Vector is not supported"); + } @chpldoc.nodoc proc init(type eltType, reader: fileReader, ref deserializer) { @@ -526,6 +530,10 @@ module EpochManager { proc writeThis(f) throws { f.write("(Vector) {", this.toArray(), "}"); } + @chpldoc.nodoc + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } } diff --git a/modules/packages/Socket.chpl b/modules/packages/Socket.chpl index 71b911124496..c07d2e4388e1 100644 --- a/modules/packages/Socket.chpl +++ b/modules/packages/Socket.chpl @@ -237,6 +237,10 @@ inline operator ==(const ref lhs: ipAddr, const ref rhs: ipAddr) { proc ipAddr.writeThis(f) throws { f.write("(","family:",this.family,",host:",this.host,",port:",this.port,")"); } +@chpldoc.nodoc +proc ipAddr.serialize(writer, ref serializer) throws { + writeThis(writer); +} /* Get a :type:`~POSIX.struct_timeval` set for indefinite timeout. @@ -325,6 +329,10 @@ inline operator ==(const ref lhs: tcpConn,const ref rhs: tcpConn) { proc tcpConn.writeThis(f) throws { f.write("(","addr:",this.addr,",fd:",this.socketFd,")"); } +@chpldoc.nodoc +proc tcpConn.serialize(writer, ref serializer) throws { + writeThis(writer); +} @chpldoc.nodoc private extern proc sizeof(e): c_size_t; @@ -777,6 +785,10 @@ inline operator ==(const ref lhs: tcpListener,const ref rhs: tcpListener) { proc tcpListener.writeThis(f) throws { f.write("(","addr:",this.addr,",fd:",this.socketFd); } +@chpldoc.nodoc +proc tcpListener.serialize(writer, ref serializer) throws { + writeThis(writer); +} @chpldoc.nodoc extern const SOMAXCONN: int; @@ -1227,6 +1239,10 @@ inline operator ==(const ref lhs: udpSocket,const ref rhs: udpSocket) { proc udpSocket.writeThis(f) throws { f.write("(","addr:",this.addr,",fd:",this.socketFd); } +@chpldoc.nodoc +proc udpSocket.serialize(writer, ref serializer) throws { + writeThis(writer); +} extern const SO_ACCEPTCONN:c_int; diff --git a/modules/packages/Sort.chpl b/modules/packages/Sort.chpl index ed6b86b27e00..8b4f6ff07deb 100644 --- a/modules/packages/Sort.chpl +++ b/modules/packages/Sort.chpl @@ -1474,6 +1474,10 @@ module SampleSortHelp { ch.write(")\n"); } + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + proc getNumBuckets() { return numBuckets * (1 + equalBuckets:int); } @@ -2232,6 +2236,10 @@ module TwoArrayPartitioning { f.write(t); } } + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + proc isEmpty() { return tasks.isEmpty(); } diff --git a/modules/packages/SortedMap.chpl b/modules/packages/SortedMap.chpl index ab68bf787578..19977cfef739 100644 --- a/modules/packages/SortedMap.chpl +++ b/modules/packages/SortedMap.chpl @@ -408,16 +408,7 @@ module SortedMap { } } - /* - Writes the contents of this sortedMap to a fileWriter. - The format looks like: - - .. code-block:: chapel - - {k1: v1, k2: v2, .... , kn: vn} - - :arg ch: A fileWriter to write to. - */ + @chpldoc.nodoc proc writeThis(ch: fileWriter) throws { _enter(); defer _leave(); var first = true; @@ -433,6 +424,11 @@ module SortedMap { ch.write("}"); } + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + /* Adds a key-value pair to the sortedMap. Method returns `false` if the key already exists in the sortedMap. diff --git a/modules/packages/SortedSet.chpl b/modules/packages/SortedSet.chpl index 63a2a8813520..c962d9ecd7dc 100644 --- a/modules/packages/SortedSet.chpl +++ b/modules/packages/SortedSet.chpl @@ -142,6 +142,11 @@ module SortedSet { instance.writeThis(ch); } + @chpldoc.nodoc + inline proc const serialize(writer, ref serializer) throws { + writeThis(writer); + } + /* The current number of elements contained in this sortedSet. */ diff --git a/modules/packages/SortedSet/Treap.chpl b/modules/packages/SortedSet/Treap.chpl index 181d3ef7fa98..d13a00e8dafd 100644 --- a/modules/packages/SortedSet/Treap.chpl +++ b/modules/packages/SortedSet/Treap.chpl @@ -823,6 +823,11 @@ module Treap { _leave(); } + @chpldoc.nodoc + proc const serialize(writer, ref serializer) throws { + writeThis(writer); + } + /* Returns `true` if this sortedSet is empty (size == 0). diff --git a/modules/packages/TOML.chpl b/modules/packages/TOML.chpl index 468ae4d6cf8d..af1bef55b01e 100644 --- a/modules/packages/TOML.chpl +++ b/modules/packages/TOML.chpl @@ -844,6 +844,10 @@ used to recursively hold tables and respective values override proc writeThis(f) throws { writeTOML(f); } + @chpldoc.nodoc + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } /* Write a Table to channel f in TOML format */ proc writeTOML(f) { @@ -1353,6 +1357,10 @@ module TomlReader { proc readThis(f) throws { compilerError("Reading a Tokens type is not supported"); } + @chpldoc.nodoc + proc deserialize(reader, ref deserializer) throws { + compilerError("Reading a Tokens type is not supported"); + } @chpldoc.nodoc proc init(reader: fileReader, ref deserializer) { @@ -1363,6 +1371,10 @@ module TomlReader { override proc writeThis(f) throws { f.write(this.A.toArray()); } + @chpldoc.nodoc + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } } diff --git a/modules/packages/UnrolledLinkedList.chpl b/modules/packages/UnrolledLinkedList.chpl index 19866098e5ea..26f4920c4e9c 100644 --- a/modules/packages/UnrolledLinkedList.chpl +++ b/modules/packages/UnrolledLinkedList.chpl @@ -1190,6 +1190,11 @@ module UnrolledLinkedList { _leave(); } + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + /* Returns `true` if this unrolledLinkedList contains zero elements. diff --git a/modules/packages/YAML.chpl b/modules/packages/YAML.chpl index 3756df079735..0f0174e9206e 100644 --- a/modules/packages/YAML.chpl +++ b/modules/packages/YAML.chpl @@ -914,6 +914,10 @@ module YAML { proc writeThis(fw) throws { fw.write("Empty YamlValue"); } + @chpldoc.nodoc + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } @chpldoc.nodoc proc asKey(): string { @@ -998,6 +1002,10 @@ module YAML { } fw.writeLiteral("}"); } + @chpldoc.nodoc + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } @chpldoc.nodoc override proc asKey(): string { @@ -1065,6 +1073,10 @@ module YAML { } fw.writeLiteral("]"); } + @chpldoc.nodoc + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } @chpldoc.nodoc override proc asKey(): string { @@ -1184,6 +1196,10 @@ module YAML { then fw.write(this.tag, " ", this.value); else fw.write(this.value); } + @chpldoc.nodoc + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } @chpldoc.nodoc override proc asKey(): string { @@ -1214,6 +1230,10 @@ module YAML { override proc writeThis(fw) throws { fw.write("*", this._alias); } + @chpldoc.nodoc + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } @chpldoc.nodoc override proc asKey(): string { diff --git a/modules/standard/AutoMath.chpl b/modules/standard/AutoMath.chpl index 726381eb2442..eb167fbd78fa 100644 --- a/modules/standard/AutoMath.chpl +++ b/modules/standard/AutoMath.chpl @@ -2700,18 +2700,14 @@ module AutoMath { pragma "last resort" @deprecated(notes="In an upcoming release 'gcd' will no longer be included by default, please 'use' or 'import' the :mod:`Math` module to call it") proc gcd(in a: int,in b: int): int { + (a, b) = (abs(a), abs(b)); return chpl_gcd(a, b); } - proc chpl_gcd(in a: int,in b: int): int { - a = abs(a); - b = abs(b); - var r: int; - while(b != 0) { - r = a % b; - a = b; - b = r; - } + proc chpl_gcd(in a,in b) { + while(b != 0) { + (a, b) = (b, a % b); + } return a; } diff --git a/modules/standard/BigInteger.chpl b/modules/standard/BigInteger.chpl index 99f9023b0e54..06d2deb31328 100644 --- a/modules/standard/BigInteger.chpl +++ b/modules/standard/BigInteger.chpl @@ -528,12 +528,17 @@ module BigInteger { @deprecated("get_str is deprecated - please use a cast to a string or IO methods to get the string representation") proc get_str(base: int = 10): string do return this.getStr(base); - /* Writes this number to a :type:`~IO.fileWriter` */ + @chpldoc.nodoc proc writeThis(writer) throws { var s: string; s = this.getStr(); writer.write(s); } + + /* Writes this number to a :type:`~IO.fileWriter` */ + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } /* An enumeration of the different rounding strategies, for use with e.g. diff --git a/modules/standard/ChapelIO.chpl b/modules/standard/ChapelIO.chpl index c9ffe8a89d87..c3b6f28ba7f7 100644 --- a/modules/standard/ChapelIO.chpl +++ b/modules/standard/ChapelIO.chpl @@ -129,6 +129,15 @@ appropriately before the elements can be read. Note that it is not currently possible to read and write circular data structures with these mechanisms. +.. _serialize-deserialize: + +The `serialize` and `deserialize` Methods +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. warning:: + + This section is currently a placeholder for forthcoming documentation. + */ pragma "module included by default" @unstable("The module name 'ChapelIO' is unstable. If you want to use qualified naming on the symbols within it, please 'use' or 'import' the :mod:`IO` module") @@ -656,6 +665,11 @@ module ChapelIO { f.write(this._instance); } + @chpldoc.nodoc + proc locale.serialize(writer, ref serializer) throws { + writer.write(this._instance); + } + @chpldoc.nodoc proc _ddata.writeThis(f) throws { compilerWarning("printing _ddata class"); @@ -814,6 +828,11 @@ module ChapelIO { } } + @chpldoc.nodoc + proc range.serialize(writer, ref serializer) throws { + writeThis(writer); + } + @chpldoc.nodoc proc ref range.readThis(f) throws { if hasLowBound() then _low = f.read(_low.type); @@ -852,6 +871,11 @@ module ChapelIO { } } + @chpldoc.nodoc + proc ref range.deserialize(reader, ref deserializer) throws { + readThis(reader); + } + @chpldoc.nodoc proc range.init(type idxType = int, param bounds : boundKind = boundKind.both, @@ -868,6 +892,11 @@ module ChapelIO { f.write(chpl_id()); } + @chpldoc.nodoc + override proc LocaleModel.serialize(writer, ref serializer) throws { + writeThis(writer); + } + /* Errors can be printed out. In that event, they will show information about the error including the result of calling :proc:`Error.message`. diff --git a/modules/standard/CommDiagnostics.chpl b/modules/standard/CommDiagnostics.chpl index 2ee6a0e827e4..509f5b84b8d0 100644 --- a/modules/standard/CommDiagnostics.chpl +++ b/modules/standard/CommDiagnostics.chpl @@ -183,6 +183,7 @@ often necessary to run a small test program twice, once with that module present and once without it. */ +@unstable("The CommDiagnostics module is unstable and may change in the future") module CommDiagnostics { /* @@ -332,6 +333,10 @@ module CommDiagnostics if first then c.write(""); c.write(")"); } + + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } }; /* diff --git a/modules/standard/Communication.chpl b/modules/standard/Communication.chpl index 90c292e893d9..a0cfebd334b0 100644 --- a/modules/standard/Communication.chpl +++ b/modules/standard/Communication.chpl @@ -29,6 +29,7 @@ under any circumstance. */ +@unstable("The Communication module is unstable and may change in the future") module Communication { private use CTypes; diff --git a/modules/standard/Heap.chpl b/modules/standard/Heap.chpl index 6a5b1b03c7ea..529b426fc4a6 100644 --- a/modules/standard/Heap.chpl +++ b/modules/standard/Heap.chpl @@ -384,6 +384,10 @@ module Heap { ch.write(this._data); _leave(); } + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } /* diff --git a/modules/standard/IO.chpl b/modules/standard/IO.chpl index 3ebb0b55aac8..bd476a9c68b3 100644 --- a/modules/standard/IO.chpl +++ b/modules/standard/IO.chpl @@ -3932,6 +3932,10 @@ record _internalIoChar { // I/O routines should handle ioChar directly assert(false); } + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } @chpldoc.nodoc @@ -4043,6 +4047,10 @@ record chpl_ioLiteral { // Normally this is handled explicitly in read/write. f.write(val); } + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } @chpldoc.nodoc diff --git a/modules/standard/Math.chpl b/modules/standard/Math.chpl index c33df7bbf1fa..dcfa786dc3f3 100644 --- a/modules/standard/Math.chpl +++ b/modules/standard/Math.chpl @@ -1045,6 +1045,52 @@ module Math { /* Returns the greatest common divisor of the integer arguments `x` and `y`. */ proc gcd(in x: int,in y: int): int { + (x, y) = (abs(x), abs(y)); + return chpl_gcd(x, y); + } + + /* Returns the greatest common divisor of the integer arguments `x` and + `y`. */ + proc gcd(in x: int(32),in y: int(32)): int(32) { + (x, y) = (abs(x), abs(y)); + return chpl_gcd(x, y); + } + + /* Returns the greatest common divisor of the integer arguments `x` and + `y`. */ + proc gcd(in x: int(16),in y: int(16)): int(16) { + (x, y) = (abs(x), abs(y)); + return chpl_gcd(x, y); + } + + /* Returns the greatest common divisor of the integer arguments `x` and + `y`. */ + proc gcd(in x: int(8),in y: int(8)): int(8) { + (x, y) = (abs(x), abs(y)); + return chpl_gcd(x, y); + } + + /* Returns the greatest common divisor of the unsigned integer arguments `x` + and `y`. */ + proc gcd(in x: uint(64),in y: uint(64)): uint(64) { + return chpl_gcd(x, y); + } + + /* Returns the greatest common divisor of the unsigned integer arguments `x` + and `y`. */ + proc gcd(in x: uint(32),in y: uint(32)): uint(32) { + return chpl_gcd(x, y); + } + + /* Returns the greatest common divisor of the unsigned integer arguments `x` + and `y`. */ + proc gcd(in x: uint(16),in y: uint(16)): uint(16) { + return chpl_gcd(x, y); + } + + /* Returns the greatest common divisor of the unsigned integer arguments `x` + and `y`. */ + proc gcd(in x: uint(8),in y: uint(8)): uint(8) { return chpl_gcd(x, y); } diff --git a/modules/standard/Random.chpl b/modules/standard/Random.chpl index 4bd09ec127e8..fa3bedb01b64 100644 --- a/modules/standard/Random.chpl +++ b/modules/standard/Random.chpl @@ -59,6 +59,7 @@ change. */ +@unstable("The Random module is unstable and may change in the future") module Random { public use RandomSupport; @@ -722,6 +723,11 @@ module Random { f.write(", parSafe=", parSafe); f.write(", seed=", seed, ")"); } + + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } } // An apparent bug prevents this from working. @@ -1374,6 +1380,11 @@ module Random { f.write(", seed=", seed, ")"); } + @chpldoc.nodoc + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + ///////////////////////////////////////////////////////// CLASS PRIVATE // // // It is the intent that once Chapel supports the notion of @@ -2858,6 +2869,11 @@ module Random { f.write(", seed=", seed, ")"); } + @chpldoc.nodoc + override proc serialize(writer, ref serializer) throws { + writeThis(writer); + } + ///////////////////////////////////////////////////////// CLASS PRIVATE // // // It is the intent that once Chapel supports the notion of diff --git a/modules/standard/Regex.chpl b/modules/standard/Regex.chpl index 849f64fad90a..d14bc4ff31ea 100644 --- a/modules/standard/Regex.chpl +++ b/modules/standard/Regex.chpl @@ -1068,6 +1068,10 @@ record regex { // and there's no way to get the flags f.write("new regex(\"", pattern, "\")"); } + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } @chpldoc.nodoc proc ref readThis(f) throws { @@ -1088,6 +1092,10 @@ record regex { this._regex); } } + @chpldoc.nodoc + proc ref deserialize(reader, ref deserializer) throws { + readThis(reader); + } @chpldoc.nodoc proc init(type exprType, reader: fileReader, ref deserializer) throws { @@ -1126,21 +1134,6 @@ inline operator :(x: regex(?exprType), type t: exprType) { return pattern; } - -// Cast string to regex -@chpldoc.nodoc -@deprecated(notes="Casting strings to regex is deprecated. Use new regex(string) from the Regex module instead.") -inline operator :(x: string, type t: regex(string)) throws { - return new regex(x); -} - -// Cast bytes to regex -@chpldoc.nodoc -@deprecated(notes="Casting bytes to regex is deprecated. Use new regex(bytes) from the Regex module instead.") -inline operator :(x: bytes, type t: regex(bytes)) throws { - return new regex(x); -} - /* Search the receiving string for the result of a compiled regular expression. Search for matches at any offset. diff --git a/modules/standard/Set.chpl b/modules/standard/Set.chpl index b6c8c6deeb5e..d259d723b0ea 100644 --- a/modules/standard/Set.chpl +++ b/modules/standard/Set.chpl @@ -542,11 +542,7 @@ module Set { if _htb.isSlotFull(idx) then yield _htb.table[idx].key; } - /* - Write the contents of this set to a channel. - - :arg ch: A channel to write to. - */ + @chpldoc.nodoc proc const writeThis(ch: fileWriter) throws { on this { _enter(); defer _leave(); @@ -567,6 +563,60 @@ module Set { } } + /* + Write the contents of this set to a fileWriter. + + :arg writer: A fileWriter to write to. + :arg serializer: The serializer to use when writing. + */ + proc const serialize(writer:fileWriter(?), ref serializer) throws { + if serializer.type == IO.defaultSerializer { + writeThis(writer); + } else { + on this { + _enter(); defer _leave(); + var ser = serializer.startList(writer, this.size); + for x in this do ser.writeElement(x); + ser.endList(); + } + } + } + + @chpldoc.nodoc + proc ref deserialize(reader, ref deserializer) throws { + on this { + _enter(); defer _leave(); + + this.clear(); + + if deserializer.type == IO.defaultDeserializer { + reader.readLiteral("{"); + + do { + this.add(reader.read(eltType)); + } while reader.matchLiteral(","); + + reader.readLiteral("}"); + } else { + var des = deserializer.startList(reader); + while des.hasMore() do + this.add(des.readElement(eltType)); + des.endList(); + } + } + } + + @chpldoc.nodoc + proc init(type eltType, param parSafe : bool, + reader, ref deserializer) throws { + this.eltType = eltType; + this.parSafe = parSafe; + + init this; + + this.deserialize(reader, deserializer); + } + /* Returns `true` if this set contains zero elements. diff --git a/modules/standard/Time.chpl b/modules/standard/Time.chpl index d464a2e76dfe..49fb19b66d9e 100644 --- a/modules/standard/Time.chpl +++ b/modules/standard/Time.chpl @@ -619,11 +619,16 @@ module Time { @chpldoc.nodoc proc date._chpldoc_workaround() { } - /* Writes this `date` formatted as ``YYYY-MM-DD`` */ + @chpldoc.nodoc proc date.writeThis(f) throws { f.write(this:string); } + /* Writes this `date` formatted as ``YYYY-MM-DD`` */ + proc date.serialize(writer, ref serializer) throws { + writeThis(writer); + } + // Exists to support some common functionality for `dateTime.readThis` @chpldoc.nodoc proc ref date._readCore(f) throws { @@ -636,7 +641,7 @@ module Time { chpl_day = f.read(int); } - /* Reads this `date` with the same format used by :proc:`date.writeThis` */ + @chpldoc.nodoc proc ref date.readThis(f) throws { import JSON.jsonDeserializer; @@ -654,6 +659,11 @@ module Time { f._readLiteral('"'); } + /* Reads this `date` with the same format used by :proc:`date.serialize` */ + proc ref date.deserialize(reader, ref deserializer) throws { + readThis(reader); + } + // // TODO: need to get this to work with the Json formatter // @@ -941,14 +951,19 @@ module Time { return str; } + @chpldoc.nodoc + proc time.writeThis(f) throws { + f.write(this:string); + } + /* Writes this `time` formatted as ``hh:mm:ss.ssssss``, followed by ``±hh:mm`` if a timezone is specified */ - proc time.writeThis(f) throws { - f.write(this:string); + proc time.serialize(writer, ref serializer) throws { + writeThis(writer); } - // Exists to support some common functionality for `dateTime.readThis` + // Exists to support some common functionality for `dateTime.deserialize` @chpldoc.nodoc proc ref time._readCore(f) throws { const colon = ":"; @@ -962,7 +977,7 @@ module Time { chpl_microsecond = f.read(int); } - /* Reads this `time` with the same format used by :proc:`time.writeThis` */ + @chpldoc.nodoc proc ref time.readThis(f) throws { import JSON.jsonDeserializer; @@ -980,6 +995,11 @@ module Time { f._readLiteral('"'); } + /* Reads this `time` with the same format used by :proc:`time.serialize` */ + proc ref time.deserialize(reader, ref deserializer) throws { + readThis(reader); + } + // // TODO: need to get this to work with the Json formatter // @@ -1672,16 +1692,19 @@ module Time { return this.strftime("%a %b %e %T %Y"); } + @chpldoc.nodoc + proc dateTime.writeThis(f) throws { + f.write(this:string); + } + /* Writes this `dateTime` formatted as ``YYYY-MM-DDThh:mm:ss.ssssss``, followed by ``±hh:mm`` if a timezone is specified */ - proc dateTime.writeThis(f) throws { - f.write(this:string); + proc dateTime.serialize(writer, ref serializer) throws { + writeThis(writer); } - /* Reads this `dateTime` with the same format used by - :proc:`dateTime.writeThis` - */ + @chpldoc.nodoc proc ref dateTime.readThis(f) throws { import JSON.jsonDeserializer; @@ -1701,6 +1724,13 @@ module Time { f._readLiteral('"'); } + /* Reads this `dateTime` with the same format used by + :proc:`dateTime.serialize` + */ + proc ref dateTime.deserialize(reader, ref deserializer) throws { + readThis(reader); + } + // // TODO: need to get this to work with the Json formatter // diff --git a/modules/standard/Version.chpl b/modules/standard/Version.chpl index 3b95861af7bd..d790c6792ccd 100644 --- a/modules/standard/Version.chpl +++ b/modules/standard/Version.chpl @@ -203,6 +203,10 @@ module Version { proc writeThis(s) throws { s.write(this:string); } + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } @chpldoc.nodoc proc init(param major: int, @@ -367,6 +371,10 @@ module Version { proc writeThis(s) throws { s.write(this:string); } + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + writeThis(writer); + } @chpldoc.nodoc proc init(major: int = -1, @@ -618,7 +626,7 @@ module Version { return v2 <= v1; } - private proc spaceship(v1: version(?), + private proc spaceship(v1: version, v2: versionValue(?)) : int { const majComp = spaceship(v1.major, v2.major); if majComp != 0 { diff --git a/test/arrays/deitz/matrix.chpl b/test/arrays/deitz/matrix.chpl index f7f78d8dcf9a..1aac2ca85083 100644 --- a/test/arrays/deitz/matrix.chpl +++ b/test/arrays/deitz/matrix.chpl @@ -8,8 +8,8 @@ record Matrix { proc const ref this(i: int, j: int) const ref do return A(i,j); } -proc Matrix.writeThis(f) throws { - f.write(A); +proc Matrix.serialize(writer, ref serializer) throws { + writer.write(A); } proc Matrix.transpose() { diff --git a/test/arrays/ferguson/semantic-examples/myrecord.chpl b/test/arrays/ferguson/semantic-examples/myrecord.chpl index 2ed98f639fa9..918222c1e12a 100644 --- a/test/arrays/ferguson/semantic-examples/myrecord.chpl +++ b/test/arrays/ferguson/semantic-examples/myrecord.chpl @@ -18,6 +18,6 @@ operator R.=(ref lhs: R, rhs: R) { lhs.x = rhs.x; } -proc R.writeThis(writer) throws { +proc R.serialize(writer, ref serializer) throws { writer.write(x); } diff --git a/test/classes/bradc/writeclass1a.chpl b/test/classes/bradc/writeclass1a.chpl index 294ec7b3ac22..f47a35587b87 100644 --- a/test/classes/bradc/writeclass1a.chpl +++ b/test/classes/bradc/writeclass1a.chpl @@ -3,8 +3,8 @@ class myclass { var y: real; } -override proc myclass.writeThis(f) throws { - f.write(x, " ", y); +override proc myclass.serialize(writer, ref serializer) throws { + writer.write(x, " ", y); } var ownA = new owned myclass(); diff --git a/test/classes/bradc/writerecord1a.chpl b/test/classes/bradc/writerecord1a.chpl index 350b866b7f01..20bf9b33cac0 100644 --- a/test/classes/bradc/writerecord1a.chpl +++ b/test/classes/bradc/writerecord1a.chpl @@ -2,8 +2,8 @@ record myrecord { var x: int; var y: real; - proc writeThis(f) throws { - f.write(x, " ", y); + proc serialize(writer, ref serializer) throws { + writer.write(x, " ", y); } } diff --git a/test/classes/deitz/record/record_user_write.chpl b/test/classes/deitz/record/record_user_write.chpl index 55fa84b1b9ab..24a531df8a9a 100644 --- a/test/classes/deitz/record/record_user_write.chpl +++ b/test/classes/deitz/record/record_user_write.chpl @@ -4,8 +4,8 @@ record foo { var z : int = 3; } -proc foo.writeThis(fp) throws { - fp.write("(---", x, " ", y, " ", z, "---)"); +proc foo.serialize(writer, ref serializer) throws { + writer.write("(---", x, " ", y, " ", z, "---)"); } var f : foo; diff --git a/test/classes/delete-free/coercions-upon-return.chpl b/test/classes/delete-free/coercions-upon-return.chpl index 11212b61bc86..3e6bd04117b2 100644 --- a/test/classes/delete-free/coercions-upon-return.chpl +++ b/test/classes/delete-free/coercions-upon-return.chpl @@ -5,7 +5,7 @@ class Gen { var Glob = new Gen(real); -proc rets(): unmanaged Gen { +proc rets(): unmanaged Gen(?) { return Glob.borrow(); } diff --git a/test/classes/delete-free/coercions-upon-yield.chpl b/test/classes/delete-free/coercions-upon-yield.chpl index 12fc9785f020..e54ad0060a99 100644 --- a/test/classes/delete-free/coercions-upon-yield.chpl +++ b/test/classes/delete-free/coercions-upon-yield.chpl @@ -5,7 +5,7 @@ class Gen { var Glob = new Gen(real); -iter rets(): unmanaged Gen { +iter rets(): unmanaged Gen(?) { yield Glob.borrow(); } diff --git a/test/classes/delete-free/lifetimes/issue-12164.chpl b/test/classes/delete-free/lifetimes/issue-12164.chpl index b4b59e9f4940..ef56d63dbd3d 100644 --- a/test/classes/delete-free/lifetimes/issue-12164.chpl +++ b/test/classes/delete-free/lifetimes/issue-12164.chpl @@ -3,14 +3,14 @@ class UserError: Error { proc init(s: string) { msg = s; } proc postinit() { writeln("init UserError"); } proc deinit() { writeln("deinit UserError"); } - override proc writeThis(f) throws { f.write("UserError: ", msg); } + override proc serialize(writer, ref serializer) throws { writer.write("UserError: ", msg); } } class Logger: Error { var x; proc init(x) { this.x = x; } proc postinit() { writeln("init Logger"); } proc deinit() { writeln("deinit Logger"); } - override proc writeThis(f) throws { f.write("[Date Time] ", x, " type:", x.type:string); } + override proc serialize(writer, ref serializer) throws { writer.write("[Date Time] ", x, " type:", x.type:string); } } proc main() { try { diff --git a/test/classes/errors/throws/writeThis/NoThrowDefaultGenParent.chpl b/test/classes/errors/throws/writeThis/NoThrowDefaultGenParent.chpl index 59a12626e094..6f8ef8514e46 100644 --- a/test/classes/errors/throws/writeThis/NoThrowDefaultGenParent.chpl +++ b/test/classes/errors/throws/writeThis/NoThrowDefaultGenParent.chpl @@ -5,8 +5,8 @@ class A { class A1: A { var y: int = 0; - proc writeThis(ch) throws { - ch.write("Hello from class A1!"); + override proc serialize(writer, ref serializer) throws { + writer.write("Hello from class A1!"); } } diff --git a/test/classes/initializers/compilerGenerated/arrayField-sync.chpl b/test/classes/initializers/compilerGenerated/arrayField-sync.chpl index da5e5cae74e3..a9cb1286b275 100644 --- a/test/classes/initializers/compilerGenerated/arrayField-sync.chpl +++ b/test/classes/initializers/compilerGenerated/arrayField-sync.chpl @@ -2,8 +2,8 @@ class C { var A : [1..10] sync int; - override proc writeThis(f) throws { - f.write(A.readXX()); + override proc serialize(writer, ref serializer) throws { + writer.write(A.readXX()); } } diff --git a/test/classes/initializers/generics/reuse-class-instantiation3.chpl b/test/classes/initializers/generics/reuse-class-instantiation3.chpl index 6591cfb701f7..65c149c01b9d 100644 --- a/test/classes/initializers/generics/reuse-class-instantiation3.chpl +++ b/test/classes/initializers/generics/reuse-class-instantiation3.chpl @@ -22,8 +22,8 @@ class Foo { this.x = val; } - override proc writeThis(f) throws { - f.write(T:string, " x=", x); + override proc serialize(writer, ref serializer) throws { + writer.write(T:string, " x=", x); } } diff --git a/test/classes/io/classToString.chpl b/test/classes/io/classToString.chpl index a590ea6cc539..350d7cd28c4b 100644 --- a/test/classes/io/classToString.chpl +++ b/test/classes/io/classToString.chpl @@ -5,10 +5,6 @@ class C { class D : C { var y: real; - proc writeThis(ch) throws { - super.writeThis(ch); - ch.write("y is: ", y); - } } class E : D { diff --git a/test/classes/weakPointers/passiveCache.good b/test/classes/weakPointers/passiveCache.good index 2296f5cb1722..0a36d69fc588 100644 --- a/test/classes/weakPointers/passiveCache.good +++ b/test/classes/weakPointers/passiveCache.good @@ -1,3 +1,6 @@ +passiveCache.chpl:4: warning: The Random module is unstable and may change in the future +passiveCache.chpl:61: In function 'main': +passiveCache.chpl:72: warning: The Random module is unstable and may change in the future passiveCache.chpl:46: In method 'buildAndSave': passiveCache.chpl:48: warning: The `weak` type is experimental; expect this API to change in the future. passiveCache.chpl:38: called as (PassiveCache(basicClass)).buildAndSave(key: int(64)) from method 'getOrBuild' diff --git a/test/constrained-generics/random/MyRandom.chpl b/test/constrained-generics/random/MyRandom.chpl index 243f15e22fbc..08a4da988d1e 100644 --- a/test/constrained-generics/random/MyRandom.chpl +++ b/test/constrained-generics/random/MyRandom.chpl @@ -672,14 +672,14 @@ module MyRandom { } @chpldoc.nodoc - proc writeThis(f) throws { - f.write("RandomStreamInterface(eltType="); - f.write(eltType:string); - f.write(", parSafe="); - f.write(parSafe); - f.write(", seed="); - f.write(seed); - f.write(")"); + proc serialize(writer, ref serializer) throws { + writer.write("RandomStreamInterface(eltType="); + writer.write(eltType:string); + writer.write(", parSafe="); + writer.write(parSafe); + writer.write(", seed="); + writer.write(seed); + writer.write(")"); } } @@ -1279,14 +1279,14 @@ module MyRandom { } @chpldoc.nodoc - override proc writeThis(f) throws { - f.write("PCGRandomStream(eltType="); - f.write(eltType:string); - f.write(", parSafe="); - f.write(parSafe); - f.write(", seed="); - f.write(seed); - f.write(")"); + override proc serialize(writer, ref serializer) throws { + writer.write("PCGRandomStream(eltType="); + writer.write(eltType:string); + writer.write(", parSafe="); + writer.write(parSafe); + writer.write(", seed="); + writer.write(seed); + writer.write(")"); } ///////////////////////////////////////////////////////// CLASS PRIVATE // @@ -2712,14 +2712,14 @@ module MyRandom { } @chpldoc.nodoc - override proc writeThis(f) throws { - f.write("NPBRandomStream(eltType="); - f.write(eltType:string); - f.write(", parSafe="); - f.write(parSafe); - f.write(", seed="); - f.write(seed); - f.write(")"); + override proc serialize(writer, ref serializer) throws { + writer.write("NPBRandomStream(eltType="); + writer.write(eltType:string); + writer.write(", parSafe="); + writer.write(parSafe); + writer.write(", seed="); + writer.write(seed); + writer.write(")"); } ///////////////////////////////////////////////////////// CLASS PRIVATE // diff --git a/test/demo/review_060130/history_accumulator.chpl b/test/demo/review_060130/history_accumulator.chpl index 3a64d0d84b5f..4cfb9612469a 100644 --- a/test/demo/review_060130/history_accumulator.chpl +++ b/test/demo/review_060130/history_accumulator.chpl @@ -44,8 +44,8 @@ operator +(x : history_real(?), y : real) { return x.f + y; } -proc history_real.writeThis(ff) throws { - ff.write(f, " ("); +proc history_real.serialize(writer, ref serializer) throws { + writer.write(f, " ("); for i in 0..#size do - ff.write(h(i), if i < size-1 then ", " else ")"); + writer.write(h(i), if i < size-1 then ", " else ")"); } diff --git a/test/deprecated/CyclicStridable.chpl b/test/deprecated/CyclicStridable.chpl index 1cdfee2604b7..2250ff0868e1 100644 --- a/test/deprecated/CyclicStridable.chpl +++ b/test/deprecated/CyclicStridable.chpl @@ -399,11 +399,11 @@ proc _cyclic_matchArgsShape(type rangeType, type scalarType, args) type { return helper(0); } -proc Cyclic.writeThis(x) throws { - x.writeln(this.type:string); - x.writeln("------"); +proc Cyclic.serialize(writer, ref serializer) throws { + writer.writeln(this.type:string); + writer.writeln("------"); for locid in targetLocDom do - x.writeln(" [", locid, "=", targetLocs(locid), "] owns chunk: ", + writer.writeln(" [", locid, "=", targetLocs(locid), "] owns chunk: ", locDist(locid).myChunk); } @@ -1078,8 +1078,8 @@ class LocCyclicArr { // guard against dynamic dispatch resolution trying to resolve // write()ing out an array of sync vars and hitting the sync var // type's compilerError() - override proc writeThis(f) throws { - halt("LocCyclicArr.writeThis() is not implemented / should not be needed"); + override proc serialize(writer, ref serializer) throws { + halt("LocCyclicArr.serialize() is not implemented / should not be needed"); } } diff --git a/test/deprecated/IO/pcnt_ht_format.good b/test/deprecated/IO/pcnt_ht_format.good index 4d581e642c0e..856e0083c101 100644 --- a/test/deprecated/IO/pcnt_ht_format.good +++ b/test/deprecated/IO/pcnt_ht_format.good @@ -1,3 +1,5 @@ +pcnt_ht_format.chpl:5: warning: 'writeThis' is deprecated. Please use 'serialize' methods instead. +pcnt_ht_format.chpl:6: warning: 'readThis' is deprecated. Please use 'deserialize' methods instead. "a string" 1 1 (a string, 2, 2) pcnt_ht_format.chpl:9: warning: The '%ht' format specifier is deprecated; please use '%?' with the Chapel-Format Serializer instead diff --git a/test/deprecated/IO/pcnt_jt_format.good b/test/deprecated/IO/pcnt_jt_format.good index dc5600883a02..b3ca1095d084 100644 --- a/test/deprecated/IO/pcnt_jt_format.good +++ b/test/deprecated/IO/pcnt_jt_format.good @@ -1,3 +1,5 @@ +pcnt_jt_format.chpl:5: warning: 'writeThis' is deprecated. Please use 'serialize' methods instead. +pcnt_jt_format.chpl:6: warning: 'readThis' is deprecated. Please use 'deserialize' methods instead. "a string" 1 1 (a string, 2, 2) pcnt_jt_format.chpl:9: warning: The '%jt' format specifier is deprecated; please use '%?' with the JSON Serializer instead diff --git a/test/deprecated/IO/pcnt_t_format.good b/test/deprecated/IO/pcnt_t_format.good index a1624d8c8caa..bfbd9d930aee 100644 --- a/test/deprecated/IO/pcnt_t_format.good +++ b/test/deprecated/IO/pcnt_t_format.good @@ -1,3 +1,5 @@ +pcnt_t_format.chpl:5: warning: 'writeThis' is deprecated. Please use 'serialize' methods instead. +pcnt_t_format.chpl:6: warning: 'readThis' is deprecated. Please use 'deserialize' methods instead. "a string" 1 1 (a string, 2, 2) pcnt_t_format.chpl:9: warning: The '%t' format specifier is deprecated; please use '%?' to invoke the type's 'serialize' method instead diff --git a/test/deprecated/URL/depReaderWriter.good b/test/deprecated/URL/depReaderWriter.good index 2c09ec645fa4..af478429e4c2 100644 --- a/test/deprecated/URL/depReaderWriter.good +++ b/test/deprecated/URL/depReaderWriter.good @@ -1,2 +1,3 @@ +depReaderWriter.chpl:1: warning: URL is unstable depReaderWriter.chpl:10: warning: openUrlReader with a style argument is deprecated depReaderWriter.chpl:11: warning: openUrlWriter with a style argument is deprecated diff --git a/test/deprecated/rangeIdxType.chpl b/test/deprecated/rangeIdxType.chpl new file mode 100644 index 000000000000..7fa4fcc1df88 --- /dev/null +++ b/test/deprecated/rangeIdxType.chpl @@ -0,0 +1,7 @@ + +writeln(( 0:int(8)..1:uint(8) ).type:string); +writeln(( 0:uint(32)..1:int(16) ).type:string); +writeln(( 0..1:int(8) ).type:string); +writeln(( 0..1:uint(8) ).type:string); +writeln(( 0:int(8)..1 ).type:string); +writeln(( 0:uint(8)..1 ).type:string); diff --git a/test/deprecated/rangeIdxType.good b/test/deprecated/rangeIdxType.good new file mode 100644 index 000000000000..7dffd025b679 --- /dev/null +++ b/test/deprecated/rangeIdxType.good @@ -0,0 +1,10 @@ +rangeIdxType.chpl:4: warning: the idxType of this range literal 0..1 with the low bound of the type int(64) and the high bound of the type int(8) is currently int(8). In a future release it will be switched to int(64). To switch to this new typing and turn off this warning, compile with -snewRangeLiteralType. +rangeIdxType.chpl:5: warning: the idxType of this range literal 0..1 with the low bound of the type int(64) and the high bound of the type uint(8) is currently uint(8). In a future release it will be switched to int(64). To switch to this new typing and turn off this warning, compile with -snewRangeLiteralType. +rangeIdxType.chpl:6: warning: the idxType of this range literal 0..1 with the low bound of the type int(8) and the high bound of the type int(64) is currently int(8). In a future release it will be switched to int(64). To switch to this new typing and turn off this warning, compile with -snewRangeLiteralType. +rangeIdxType.chpl:7: warning: the idxType of this range literal 0..1 with the low bound of the type uint(8) and the high bound of the type int(64) is currently uint(8). In a future release it will be switched to int(64). To switch to this new typing and turn off this warning, compile with -snewRangeLiteralType. +range(uint(8),both,one) +range(uint(32),both,one) +range(int(8),both,one) +range(uint(8),both,one) +range(int(8),both,one) +range(uint(8),both,one) diff --git a/test/deprecated/regexTertiary.chpl b/test/deprecated/regexTertiary.chpl deleted file mode 100644 index 506d9f9d5d5d..000000000000 --- a/test/deprecated/regexTertiary.chpl +++ /dev/null @@ -1,16 +0,0 @@ -use Regex; // vass: deprecated for 1.29.0 - -writeln("Search"); -{ -var s = "contains"; -var b = b"contains"; -// check deprecation of casts string|bytes --> regex -var rs = s:regex(string); -var rb = b:regex(bytes); - -writeln(rs.search("contains regular expression")); -writeln(rb.search(b"contains regular expression")); - -writeln(rs.search("doesn't contain regular expression")); -writeln(rb.search(b"doesn't contain regular expression")); -} diff --git a/test/deprecated/regexTertiary.good b/test/deprecated/regexTertiary.good deleted file mode 100644 index f9cbe285e482..000000000000 --- a/test/deprecated/regexTertiary.good +++ /dev/null @@ -1,7 +0,0 @@ -regexTertiary.chpl:8: warning: Casting strings to regex is deprecated. Use new regex(string) from the Regex module instead. -regexTertiary.chpl:9: warning: Casting bytes to regex is deprecated. Use new regex(bytes) from the Regex module instead. -Search -(matched = true, byteOffset = 0, numBytes = 8) -(matched = true, byteOffset = 0, numBytes = 8) -(matched = false, byteOffset = -1, numBytes = 0) -(matched = false, byteOffset = -1, numBytes = 0) diff --git a/test/deprecated/regexTertiary.skipif b/test/deprecated/regexTertiary.skipif deleted file mode 100644 index ae2280573298..000000000000 --- a/test/deprecated/regexTertiary.skipif +++ /dev/null @@ -1 +0,0 @@ -CHPL_RE2==none diff --git a/test/distributions/diten/Cyclic.chpl b/test/distributions/diten/Cyclic.chpl index 16dcee39e01e..a92a150e95d2 100644 --- a/test/distributions/diten/Cyclic.chpl +++ b/test/distributions/diten/Cyclic.chpl @@ -116,14 +116,14 @@ class Cyclic1DDist { // - proc writeThis(x) throws { - x.writeln("Cyclic1DPar"); - x.writeln("---------------"); - x.writeln("across locales: ", targetLocs); - x.writeln("indexed via: ", targetLocDom); - x.writeln("resulting in: "); + proc serialize(writer, ref serializer) throws { + writer.writeln("Cyclic1DPar"); + writer.writeln("---------------"); + writer.writeln("across locales: ", targetLocs); + writer.writeln("indexed via: ", targetLocDom); + writer.writeln("resulting in: "); for locid in targetLocDom do - x.writeln(" [", locid, "] ", locDist(locid)); + writer.writeln(" [", locid, "] ", locDist(locid)); } @@ -205,8 +205,8 @@ class LocCyclic1DDist { writeln("locale ", locid, " owns ", myChunk); } - proc writeThis(x) throws { - x.write("locale ", loc.id, " owns chunk: ", myChunk); + proc serialize(writer, ref serializer) throws { + writer.write("locale ", loc.id, " owns chunk: ", myChunk); } } @@ -352,8 +352,8 @@ class Cyclic1DDom { // // the print method for the domain // - proc writeThis(x) throws { - x.write(whole); + proc serialize(writer, ref serializer) throws { + writer.write(whole); } // @@ -430,8 +430,8 @@ class LocCyclic1DDom { // // how to write out this locale's indices // - proc writeThis(x) throws { - x.write(myBlock); + proc serialize(writer, ref serializer) throws { + writer.write(myBlock); } // @@ -542,7 +542,7 @@ class Cyclic1DArr { // // how to print out the whole array, sequentially // - proc writeThis(x) throws { + override proc serialize(writer, ref serializer) throws { var first = true; for loc in dom.dist.targetLocDom { // May want to do something like the following: @@ -552,11 +552,11 @@ class Cyclic1DArr { if (first) { first = false; } else { - x.write(" "); + writer.write(" "); } if debugCyclic1D then writeln("Writing elements on locale: ", loc); - x.write(locArr(loc)); + writer.write(locArr(loc)); } // } stdout.flush(); @@ -628,11 +628,11 @@ class LocCyclic1DArr { // // prints out this locale's piece of the array // - proc writeThis(x) throws { + override proc serialize(writer, ref serializer) throws { // May want to do something like the following: // on loc { // but it causes deadlock -- see writeThisUsingOn.chpl - x.write(myElems); + writer.write(myElems); } // diff --git a/test/domains/diten/multitypeIndex.compopts b/test/domains/diten/multitypeIndex.compopts new file mode 100644 index 000000000000..dea20e009ab0 --- /dev/null +++ b/test/domains/diten/multitypeIndex.compopts @@ -0,0 +1 @@ +-snewRangeLiteralType diff --git a/test/errors/parsing/stringLiteralLocations.1.good b/test/errors/parsing/stringLiteralLocations.1.good new file mode 100644 index 000000000000..cbadf186c0dc --- /dev/null +++ b/test/errors/parsing/stringLiteralLocations.1.good @@ -0,0 +1,4 @@ +stringLiteralLocations.chpl:4: syntax error: incorrect expression in 'except' list, identifier expected +stringLiteralLocations.chpl:5: syntax error: incorrect expression in 'except' list, identifier expected +stringLiteralLocations.chpl:6: syntax error: incorrect expression in 'except' list, identifier expected +stringLiteralLocations.chpl:7: syntax error: incorrect expression in 'except' list, identifier expected diff --git a/test/errors/parsing/stringLiteralLocations.2.good b/test/errors/parsing/stringLiteralLocations.2.good new file mode 100644 index 000000000000..c738f75d4599 --- /dev/null +++ b/test/errors/parsing/stringLiteralLocations.2.good @@ -0,0 +1,32 @@ +─── syntax in stringLiteralLocations.chpl:4 [ExceptOnlyInvalidExpr] ─── + Incorrect expression in 'except' list, identifier expected. + In the 'except' list here: + | + 4 | use IO except "hello"; + | ⎺⎺⎺⎺⎺⎺⎺ + | + +─── syntax in stringLiteralLocations.chpl:5 [ExceptOnlyInvalidExpr] ─── + Incorrect expression in 'except' list, identifier expected. + In the 'except' list here: + | + 5 | use IO except b"hello"; + | ⎺⎺⎺⎺⎺⎺⎺⎺ + | + +─── syntax in stringLiteralLocations.chpl:6 [ExceptOnlyInvalidExpr] ─── + Incorrect expression in 'except' list, identifier expected. + In the 'except' list here: + | + 6 | use IO except """hello"""; + | ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ + | + +─── syntax in stringLiteralLocations.chpl:7 [ExceptOnlyInvalidExpr] ─── + Incorrect expression in 'except' list, identifier expected. + In the 'except' list here: + | + 7 | use IO except b"""hello"""; + | ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ + | + diff --git a/test/errors/parsing/stringLiteralLocations.chpl b/test/errors/parsing/stringLiteralLocations.chpl new file mode 100644 index 000000000000..0dd1d33d918d --- /dev/null +++ b/test/errors/parsing/stringLiteralLocations.chpl @@ -0,0 +1,7 @@ +// The easiest way to get Dyno to print string literals is to cause an error, +// in this case by trying to use a string literal in an 'except' clause. + +use IO except "hello"; +use IO except b"hello"; +use IO except """hello"""; +use IO except b"""hello"""; diff --git a/test/exercises/duplicates/forStudents/FileHashing.chpl b/test/exercises/duplicates/forStudents/FileHashing.chpl index 912bca86b854..d89c50089fb1 100644 --- a/test/exercises/duplicates/forStudents/FileHashing.chpl +++ b/test/exercises/duplicates/forStudents/FileHashing.chpl @@ -11,10 +11,10 @@ module FileHashing { in a good format. */ - proc writeThis(f) throws { + proc serialize(writer, ref serializer) throws { for component in hashVal { var s = try! "%08xu".format(component); - f.write(s); + writer.write(s); } } diff --git a/test/functions/compilation-errors/recursive-generic-return.good b/test/functions/compilation-errors/recursive-generic-return.good index 0972879a2fd7..c1779f1abdb4 100644 --- a/test/functions/compilation-errors/recursive-generic-return.good +++ b/test/functions/compilation-errors/recursive-generic-return.good @@ -1,2 +1,6 @@ +recursive-generic-return.chpl:8: warning: please use '?' when declaring a routine with a generic return type +recursive-generic-return.chpl:8: note: for example with 'RR(?)' recursive-generic-return.chpl:12: warning: RR(int(64)) +recursive-generic-return.chpl:15: warning: please use '?' when declaring a routine with a generic return type +recursive-generic-return.chpl:15: note: for example with 'RR(?)' recursive-generic-return.chpl:15: error: could not determine the concrete type for the generic return type 'RR' diff --git a/test/functions/ferguson/ref-pair/tuples/bug-12282.chpl b/test/functions/ferguson/ref-pair/tuples/bug-12282.chpl index 116efdc666cc..71e90c891ed5 100644 --- a/test/functions/ferguson/ref-pair/tuples/bug-12282.chpl +++ b/test/functions/ferguson/ref-pair/tuples/bug-12282.chpl @@ -1,7 +1,7 @@ record item { var data: int = 0; - proc writeThis(f) throws { f.write(data); } + proc serialize(writer, ref serializer) throws { writer.write(data); } } record itemset { diff --git a/test/functions/generic/genericReturnQ.chpl b/test/functions/generic/genericReturnQ.chpl new file mode 100644 index 000000000000..25182dfb5ae2 --- /dev/null +++ b/test/functions/generic/genericReturnQ.chpl @@ -0,0 +1,50 @@ +record CR { var x: int; } +record GR { type t; var x: t; } +record GRD { type t=int; var x: t; } +class CC { var x: int; } +class GC { type t; var x: t; } + +proc crNoQ(): CR { // OK + return new CR(1); +} +writeln(crNoQ()); + + +proc grNoQ(): GR { // expect a warning + return new GR(int, 1); +} +writeln(grNoQ()); + +proc grQ(): GR(?) { // OK + return new GR(int, 1); +} +writeln(grQ()); + + +proc grdNoQ(): GRD { // OK + return new GRD(int, 1); +} +writeln(grdNoQ()); + +proc grdQ(): GRD(?) { // OK + return new GRD(int, 1); +} +writeln(grdQ()); + + +proc ccNoQ(): CC { // OK + return new CC(1); +} +writeln(ccNoQ()); + + +proc gcNoQ(): GC { // expect a warning + return new GC(int, 1); +} +writeln(gcNoQ()); + +proc gcQ(): GC(?) { // OK + return new GC(int, 1); +} +writeln(gcQ()); + diff --git a/test/functions/generic/genericReturnQ.good b/test/functions/generic/genericReturnQ.good new file mode 100644 index 000000000000..10c08019cd02 --- /dev/null +++ b/test/functions/generic/genericReturnQ.good @@ -0,0 +1,12 @@ +genericReturnQ.chpl:13: warning: please use '?' when declaring a routine with a generic return type +genericReturnQ.chpl:13: note: for example with 'GR(?)' +genericReturnQ.chpl:41: warning: please use '?' when declaring a routine with a generic return type +genericReturnQ.chpl:41: note: for example with 'GC(?)' +(x = 1) +(x = 1) +(x = 1) +(x = 1) +(x = 1) +{x = 1} +{x = 1} +{x = 1} diff --git a/test/functions/generic/notGenericQ-formal.chpl b/test/functions/generic/notGenericQ-formal.chpl new file mode 100644 index 000000000000..fd694f402003 --- /dev/null +++ b/test/functions/generic/notGenericQ-formal.chpl @@ -0,0 +1,5 @@ +record R { } + +proc a(x: R(?)) { } +var r: R; +a(r); diff --git a/test/functions/generic/notGenericQ-formal.good b/test/functions/generic/notGenericQ-formal.good new file mode 100644 index 000000000000..767e2e14b59f --- /dev/null +++ b/test/functions/generic/notGenericQ-formal.good @@ -0,0 +1 @@ +notGenericQ-formal.chpl:3: error: the formal argument 'x' is marked generic with (?) but the type 'R' is not generic diff --git a/test/functions/generic/notGenericQ-return.chpl b/test/functions/generic/notGenericQ-return.chpl new file mode 100644 index 000000000000..57cf2a66df43 --- /dev/null +++ b/test/functions/generic/notGenericQ-return.chpl @@ -0,0 +1,6 @@ +record R { } + +proc b() : R(?) { + return new R(); +} +b(); diff --git a/test/functions/generic/notGenericQ-return.good b/test/functions/generic/notGenericQ-return.good new file mode 100644 index 000000000000..46ae477e3b49 --- /dev/null +++ b/test/functions/generic/notGenericQ-return.good @@ -0,0 +1 @@ +notGenericQ-return.chpl:3: error: the return type of the routine b is marked generic with (?) but the type 'R' is not generic diff --git a/test/functions/generic/poi/bug-14185.chpl b/test/functions/generic/poi/bug-14185.chpl index 8244d8d2b487..bf9ffade9727 100644 --- a/test/functions/generic/poi/bug-14185.chpl +++ b/test/functions/generic/poi/bug-14185.chpl @@ -2,8 +2,8 @@ module NewTypeMod { record NewType { var x: int; - proc writeThis(f) throws { - f.write("NewType with ", x); + proc serialize(writer, ref serializer) throws { + writer.write("NewType with ", x); } } } diff --git a/test/functions/generic/poi/writethis-user-record.chpl b/test/functions/generic/poi/writethis-user-record.chpl index f79cb94bd70d..83ff1c486c83 100644 --- a/test/functions/generic/poi/writethis-user-record.chpl +++ b/test/functions/generic/poi/writethis-user-record.chpl @@ -3,7 +3,7 @@ This code summarizes what happens upon: record Color { var red, green, blue: uint(8); - proc writeThis(channel) { } // can be user-defined or compiler-generated + proc serialize(writer, ref serializer) { } // can be user-defined or compiler-generated } var taupe = new Color(179, 139, 109); @@ -16,7 +16,7 @@ where the module IO.chpl has: } ..... more wrappers ..... proc _write_one_internal(....) { - arg.writeThis(channel) + arg.serialize(writer, ref serializer) } */ diff --git a/test/functions/iterators/recursive/recursive-generic-declared-type.bad b/test/functions/iterators/recursive/recursive-generic-declared-type.bad index 6e4ccb5adb3b..6416e2a74634 100644 --- a/test/functions/iterators/recursive/recursive-generic-declared-type.bad +++ b/test/functions/iterators/recursive/recursive-generic-declared-type.bad @@ -1,4 +1,8 @@ +recursive-generic-declared-type.chpl:8: warning: please use '?' when declaring a routine with a generic return type +recursive-generic-declared-type.chpl:8: note: for example with 'RR(?)' recursive-generic-declared-type.chpl:13: warning: RR(int(64)) +recursive-generic-declared-type.chpl:17: warning: please use '?' when declaring a routine with a generic return type +recursive-generic-declared-type.chpl:17: note: for example with 'RR(?)' recursive-generic-declared-type.chpl:17: In iterator 'recIter': recursive-generic-declared-type.chpl:18: error: cannot default-initialize a variable with generic type recursive-generic-declared-type.chpl:18: note: '' has generic type 'RR' diff --git a/test/functions/iterators/vass/const-ref-iterator-1.chpl b/test/functions/iterators/vass/const-ref-iterator-1.chpl index 7cd229e865e6..073eb5b99200 100644 --- a/test/functions/iterators/vass/const-ref-iterator-1.chpl +++ b/test/functions/iterators/vass/const-ref-iterator-1.chpl @@ -134,7 +134,7 @@ iter dy_r2() ref :RR { } for i in dy_r2() do writeln(i); -iter dy_cr3() const ref :QQ { +iter dy_cr3() const ref :QQ(?) { yield v3; yield c3; yield ref3(); @@ -143,7 +143,7 @@ iter dy_cr3() const ref :QQ { } for i in dy_cr3() do writeln(i); -iter dy_r3() ref :QQ { +iter dy_r3() ref :QQ(?) { yield v3; yield c3; //error yield ref3(); @@ -190,7 +190,7 @@ iter df_r2() ref :typ2() { } for i in df_r2() do writeln(i); -iter df_cr3() const ref :typ3() { +iter df_cr3() const ref :typ3()(?) { yield v3; yield c3; yield ref3(); @@ -199,7 +199,7 @@ iter df_cr3() const ref :typ3() { } for i in df_cr3() do writeln(i); -iter df_r3() ref :typ3() { +iter df_r3() ref :typ3()(?) { yield v3; yield c3; //error yield ref3(); diff --git a/test/functions/iterators/vass/const-ref-iterator-4.chpl b/test/functions/iterators/vass/const-ref-iterator-4.chpl index e2f5ce1ebc71..de7e9a8ef027 100644 --- a/test/functions/iterators/vass/const-ref-iterator-4.chpl +++ b/test/functions/iterators/vass/const-ref-iterator-4.chpl @@ -100,7 +100,7 @@ iter dy_r2() ref :RR { } for i in dy_r2() do writeln(i); -iter dy_cr3() const ref :QQ { +iter dy_cr3() const ref :QQ(?) { yield v3; yield c3; yield ref3(); @@ -108,7 +108,7 @@ iter dy_cr3() const ref :QQ { } for i in dy_cr3() do writeln(i); -iter dy_r3() ref :QQ { +iter dy_r3() ref :QQ(?) { yield v3; yield ref3(); } @@ -144,7 +144,7 @@ iter df_r2() ref :typ2() { } for i in df_r2() do writeln(i); -iter df_cr3() const ref :typ3() { +iter df_cr3() const ref :typ3()(?) { yield v3; yield c3; yield ref3(); @@ -152,7 +152,7 @@ iter df_cr3() const ref :typ3() { } for i in df_cr3() do writeln(i); -iter df_r3() ref :typ3() { +iter df_r3() ref :typ3()(?) { yield v3; yield ref3(); } diff --git a/test/functions/lydia/declaredGenericReturnType.chpl b/test/functions/lydia/declaredGenericReturnType.chpl index 9f0b1bc7bf6f..e860be534486 100644 --- a/test/functions/lydia/declaredGenericReturnType.chpl +++ b/test/functions/lydia/declaredGenericReturnType.chpl @@ -4,7 +4,7 @@ record Rec { type t; } -proc retsRec(type t): Rec { +proc retsRec(type t): Rec(?) { return new Rec(t); } @@ -23,7 +23,7 @@ var GlobClass = new owned Gen(real); /// owned, explicit /// -proc retsGenOE(type t): owned Gen { +proc retsGenOE(type t): owned Gen(?) { return new owned Gen(t); } @@ -34,7 +34,7 @@ compilerWarning(yOE.type: string); /// shared, explicit /// -proc retsGenSE(type t): shared Gen { +proc retsGenSE(type t): shared Gen(?) { return new shared Gen(t); } @@ -45,7 +45,7 @@ compilerWarning(ySE.type: string); /// borrowed, explicit /// -proc retsGenBE(type t): borrowed Gen { +proc retsGenBE(type t): borrowed Gen(?) { return GlobClass; // implicit conversion to borrowed } @@ -54,7 +54,7 @@ compilerWarning(xBE.type: string); /// unmanaged, explicit /// -proc retsGenUE(type t): unmanaged Gen { +proc retsGenUE(type t): unmanaged Gen(?) { return new unmanaged Gen(t); } diff --git a/test/functions/this/bradc/domainSliceConfusion.compopts b/test/functions/this/bradc/domainSliceConfusion.compopts new file mode 100644 index 000000000000..dea20e009ab0 --- /dev/null +++ b/test/functions/this/bradc/domainSliceConfusion.compopts @@ -0,0 +1 @@ +-snewRangeLiteralType diff --git a/test/functions/vass/declaredGenericReturnTuple.chpl b/test/functions/vass/declaredGenericReturnTuple.chpl index 4f8f8f7de3ee..302547250260 100644 --- a/test/functions/vass/declaredGenericReturnTuple.chpl +++ b/test/functions/vass/declaredGenericReturnTuple.chpl @@ -5,16 +5,16 @@ class VectorListElement { var x; } const ownVLE = new owned VectorListElement(7); const VLE = ownVLE.borrow(); -proc p1(): VectorListElement { return VLE; } +proc p1(): VectorListElement(?) { return VLE; } writeln(p1()); -proc p2(): (VectorListElement,) { return (VLE,); } +proc p2(): (VectorListElement(?),) { return (VLE,); } writeln(p2()); -iter i1(): VectorListElement { yield VLE; } +iter i1(): VectorListElement(?) { yield VLE; } for j1 in i1() do writeln(j1); -iter i2(): (VectorListElement,) { yield (VLE,); } +iter i2(): (VectorListElement(?),) { yield (VLE,); } for j2 in i2() do writeln(j2); // Ensure that these tuples are generic. diff --git a/test/gpu/interop/cuBLAS/cuBLAS.chpl b/test/gpu/interop/cuBLAS/cuBLAS.chpl index 3637aa7ef004..22e105869592 100644 --- a/test/gpu/interop/cuBLAS/cuBLAS.chpl +++ b/test/gpu/interop/cuBLAS/cuBLAS.chpl @@ -31,7 +31,7 @@ module cuBLAS { return gpu_ptr; } - proc gpu_to_cpu(dst_ptr: c_ptr(void), src_ptr: DevicePtr, size: c_size_t){ + proc gpu_to_cpu(dst_ptr: c_ptr(void), src_ptr: DevicePtr(?), size: c_size_t){ require "c_cublas.h", "c_cublas.o"; to_cpu(dst_ptr, src_ptr.val, size); } diff --git a/test/io/bradc/multilocale/testdistwrite.chpl b/test/io/bradc/multilocale/testdistwrite.chpl index 673ef6845896..9c703fda8b7c 100644 --- a/test/io/bradc/multilocale/testdistwrite.chpl +++ b/test/io/bradc/multilocale/testdistwrite.chpl @@ -5,10 +5,10 @@ class D { class C { var Ds: [LocaleSpace] unmanaged D?; - proc writeThis(x) throws { + override proc serialize(writer, ref serializer) throws { for loc in Locales do on loc do - Ds[loc.id]!.writeThis(x); + Ds[loc.id]!.serialize(writer, serializer); } } diff --git a/test/io/errors/writeThisUserError.chpl b/test/io/errors/writeThisUserError.chpl index 3900a67fd096..12175c565110 100644 --- a/test/io/errors/writeThisUserError.chpl +++ b/test/io/errors/writeThisUserError.chpl @@ -8,10 +8,10 @@ use IO; record foo { var x: int = 0; - proc writeThis(ch: fileWriter(?)) throws { + proc serialize(writer:fileWriter(?), ref serializer) throws { throw new IllegalArgumentError('User error thrown from writeThis!'); - ch.write(x); + writer.write(x); } } diff --git a/test/io/ferguson/readThis/read-write-locale-arg.chpl b/test/io/ferguson/readThis/read-write-locale-arg.chpl index 3c4594ef6e24..e16e6ffaf9e2 100644 --- a/test/io/ferguson/readThis/read-write-locale-arg.chpl +++ b/test/io/ferguson/readThis/read-write-locale-arg.chpl @@ -2,9 +2,9 @@ use IO; class A { var x:int; - proc writeThis(writer) throws { + override proc serialize(writer, ref serializer) throws { var loc = writer.readWriteThisFromLocale(); - writeln("in A.writeThis loc= ", loc.id); + writeln("in A.serialize loc= ", loc.id); writer.writeln(x); } } @@ -12,37 +12,37 @@ class A { class B { var x:int; proc init(x: int = 0) { this.x = x; } - proc init(r: fileReader(?)) { - var loc = r.readWriteThisFromLocale(); - writeln("in B.readThis loc= ", loc.id); - this.x = r.readln(int); + proc init(reader: fileReader(?), ref deserializer) { + var loc = reader.readWriteThisFromLocale(); + writeln("in B.init loc= ", loc.id); + this.x = reader.readln(int); } - proc readThis(writer) throws { - var loc = writer.readWriteThisFromLocale(); - writeln("in B.readThis loc= ", loc.id); - writer.readln(x); + override proc deserialize(reader, ref deserializer) throws { + var loc = reader.readWriteThisFromLocale(); + writeln("in B.deserialize loc= ", loc.id); + reader.readln(x); } } class C { var x:int; proc init(x: int = 0) { this.x = x; } - proc init(r: fileReader(?)) { - var loc = r.readWriteThisFromLocale(); - writeln("in C.readWriteHelper loc= ", loc.id); - this.x = r.read(int); + proc init(reader: fileReader(?), ref deserializer) { + var loc = reader.readWriteThisFromLocale(); + writeln("in C.init loc= ", loc.id); + this.x = reader.read(int); } - proc readThis(r) throws { - var loc = r.readWriteThisFromLocale(); - writeln("in C.readThis loc= ", loc.id); - r.read(x); + override proc deserialize(reader, ref deserializer) throws { + var loc = reader.readWriteThisFromLocale(); + writeln("in C.deserialize loc= ", loc.id); + reader.read(x); } - proc writeThis(w) throws { - var loc = w.readWriteThisFromLocale(); - writeln("in C.writeThis loc= ", loc.id); - w.write(x); + override proc serialize(writer, ref serializer) throws { + var loc = writer.readWriteThisFromLocale(); + writeln("in C.serialize loc= ", loc.id); + writer.write(x); } } diff --git a/test/io/ferguson/readThis/read-write-locale-arg.good b/test/io/ferguson/readThis/read-write-locale-arg.good index 03cdb494019f..a8d7ff71fbc8 100644 --- a/test/io/ferguson/readThis/read-write-locale-arg.good +++ b/test/io/ferguson/readThis/read-write-locale-arg.good @@ -1,12 +1,12 @@ Writes from Locale 1 -in A.writeThis loc= 1 -in C.writeThis loc= 1 +in A.serialize loc= 1 +in C.serialize loc= 1 Writes from Locale 2 -in A.writeThis loc= 2 -in C.writeThis loc= 2 +in A.serialize loc= 2 +in C.serialize loc= 2 Reads from Locale 1 -in B.readThis loc= 1 -in C.readThis loc= 1 +in B.deserialize loc= 1 +in C.deserialize loc= 1 Reads from Locale 2 -in B.readThis loc= 2 -in C.readThis loc= 2 +in B.deserialize loc= 2 +in C.deserialize loc= 2 diff --git a/test/io/ferguson/readThis/read-write-locale-inner.chpl b/test/io/ferguson/readThis/read-write-locale-inner.chpl index c6c5ee011a0a..df3640fe26cc 100644 --- a/test/io/ferguson/readThis/read-write-locale-inner.chpl +++ b/test/io/ferguson/readThis/read-write-locale-inner.chpl @@ -1,16 +1,16 @@ record A { var x:int; - proc writeThis(writer) throws { + proc serialize(writer, ref serializer) throws { var loc = writer.readWriteThisFromLocale(); - writeln("in A.writeThis loc=", loc.id); + writeln("in A.serialize loc=", loc.id); writer.write(x); } } record B { var a:A; - proc writeThis(writer) throws { + proc serialize(writer, ref serializer) throws { var loc = writer.readWriteThisFromLocale(); - writeln("in B.writeThis loc=", loc.id); + writeln("in B.serialize loc=", loc.id); writer.write(a); } } diff --git a/test/io/ferguson/readThis/read-write-locale-inner.good b/test/io/ferguson/readThis/read-write-locale-inner.good index 5509bf3b2ac0..eca2fdb428f2 100644 --- a/test/io/ferguson/readThis/read-write-locale-inner.good +++ b/test/io/ferguson/readThis/read-write-locale-inner.good @@ -1,3 +1,3 @@ -in B.writeThis loc=1 -in A.writeThis loc=1 +in B.serialize loc=1 +in A.serialize loc=1 1 diff --git a/test/io/ferguson/readThis/read-write-locale-on.chpl b/test/io/ferguson/readThis/read-write-locale-on.chpl index a27ef4615e7a..c26378e5f140 100644 --- a/test/io/ferguson/readThis/read-write-locale-on.chpl +++ b/test/io/ferguson/readThis/read-write-locale-on.chpl @@ -1,18 +1,18 @@ record A { var x:int; - proc writeThis(writer) throws { + proc serialize(writer, ref serializer) throws { var loc = writer.readWriteThisFromLocale(); - writer.writeln("in A.writeThis loc=", loc.id); + writer.writeln("in A.serialize loc=", loc.id); writer.writeln(x); } } record B { var a:A; - proc writeThis(writer) throws { + proc serialize(writer, ref serializer) throws { var loc = writer.readWriteThisFromLocale(); - writer.writeln("in B.writeThis loc=", loc.id); + writer.writeln("in B.serialize loc=", loc.id); on loc { - writer.writeln("in B.writeThis on loc"); + writer.writeln("in B.serialize on loc"); writer.writeln(a); // Note, since stdout is locked at this point, // and since the recursive locking isn't multi-locale diff --git a/test/io/ferguson/readThis/read-write-locale-on.good b/test/io/ferguson/readThis/read-write-locale-on.good index cb3d41611995..bb783531067d 100644 --- a/test/io/ferguson/readThis/read-write-locale-on.good +++ b/test/io/ferguson/readThis/read-write-locale-on.good @@ -1,5 +1,5 @@ -in B.writeThis loc=1 -in B.writeThis on loc -in A.writeThis loc=1 +in B.serialize loc=1 +in B.serialize on loc +in A.serialize loc=1 1 diff --git a/test/io/ferguson/readThis/readclass.chpl b/test/io/ferguson/readThis/readclass.chpl index 28e019ed98eb..5bdebf76fa15 100644 --- a/test/io/ferguson/readThis/readclass.chpl +++ b/test/io/ferguson/readThis/readclass.chpl @@ -3,14 +3,16 @@ use IO; class mything { var x:int; proc init(x: int = 0) { this.x = x; } - proc init(r: fileReader(?)) { this.x = r.read(int); } + proc init(reader: fileReader(?), ref deserializer) { + this.x = reader.read(int); + } - proc readThis(r) throws { - r.read(x); + override proc deserialize(reader, ref deserializer) throws { + reader.read(x); } - proc writeThis(w) throws { - w.write(x); + override proc serialize(writer, ref serializer) throws { + writer.write(x); } } @@ -20,22 +22,22 @@ class subthing : mything { super.init(x); this.y = y; } - proc init(r: fileReader(?)) { - this.x = r.read(int); - r.readLiteral(","); - this.y = r.read(int); + proc init(reader: fileReader(?), ref deserializer) { + this.x = reader.read(int); + reader.readLiteral(","); + this.y = reader.read(int); } - override proc readThis(r) throws { - x = r.read(int); - r.readLiteral(","); - y = r.read(int); + override proc deserialize(reader, ref deserializer) throws { + x = reader.read(int); + reader.readLiteral(","); + y = reader.read(int); } - override proc writeThis(w) throws { - w.write(x); - w.writeLiteral(","); - w.write(y); + override proc serialize(writer, ref serializer) throws { + writer.write(x); + writer.writeLiteral(","); + writer.write(y); } } diff --git a/test/io/ferguson/readThis/readclass2.chpl b/test/io/ferguson/readThis/readclass2.chpl index 732ff42b7173..ab2d4d706831 100644 --- a/test/io/ferguson/readThis/readclass2.chpl +++ b/test/io/ferguson/readThis/readclass2.chpl @@ -8,22 +8,22 @@ class mything { this.x = x; this.y = y; } - proc init(r: fileReader(?)) { - this.x = r.read(int); - r.readLiteral(" "); - this.y = r.read(int); + proc init(reader, ref deserializer) { + this.x = reader.read(int); + reader.readLiteral(" "); + this.y = reader.read(int); } - proc readThis(r) throws { - x = r.read(int); - r.readLiteral(" "); - y = r.read(int); + override proc deserialize(reader, ref deserializer) throws { + x = reader.read(int); + reader.readLiteral(" "); + y = reader.read(int); } - proc writeThis(w) throws { - w.write(x); - w.writeLiteral(" "); - w.write(y); + override proc serialize(writer, ref serializer) throws { + writer.write(x); + writer.writeLiteral(" "); + writer.write(y); } } diff --git a/test/io/ferguson/readThis/readclass3.chpl b/test/io/ferguson/readThis/readclass3.chpl index ac891a6f51a0..743b11aca75d 100644 --- a/test/io/ferguson/readThis/readclass3.chpl +++ b/test/io/ferguson/readThis/readclass3.chpl @@ -7,22 +7,22 @@ class mything { this.x = x; this.y = y; } - proc init(r: fileReader(?)) { - this.x = r.read(int); - r.readLiteral(" "); - this.y = r.read(int); + proc init(reader, ref deserializer) { + this.x = reader.read(int); + reader.readLiteral(" "); + this.y = reader.read(int); } - proc readThis(r) throws { - x = r.read(int); - r.readLiteral(" "); - y = r.read(int); + override proc deserialize(reader, ref deserializer) throws { + x = reader.read(int); + reader.readLiteral(" "); + y = reader.read(int); } - proc writeThis(w) throws { - w.write(x); - w.writeLiteral(" "); - w.write(y); + override proc serialize(writer, ref serializer) throws { + writer.write(x); + writer.writeLiteral(" "); + writer.write(y); } } diff --git a/test/io/ferguson/readThis/readclass4.chpl b/test/io/ferguson/readThis/readclass4.chpl index 2967e7dfa6de..60dbf22374a1 100644 --- a/test/io/ferguson/readThis/readclass4.chpl +++ b/test/io/ferguson/readThis/readclass4.chpl @@ -3,8 +3,8 @@ use IO; class mything { var x:int; var y:int; - proc writeThis(w: fileWriter) throws { - w.writeln(x, " ", y); + override proc serialize(writer, ref serializer) throws { + writer.writeln(x, " ", y); } // no readThis. Expect a compile-time error } diff --git a/test/io/ferguson/readThis/readclass5.chpl b/test/io/ferguson/readThis/readclass5.chpl index 079e26409ddb..f7d2beebbdb9 100644 --- a/test/io/ferguson/readThis/readclass5.chpl +++ b/test/io/ferguson/readThis/readclass5.chpl @@ -7,25 +7,25 @@ class mything { this.x = x; this.y = y; } - proc init(r: fileReader(?)) { - this.x = r.read(int); - r.readLiteral(" "); - this.y = r.read(int); - r.readNewline(); + proc init(reader, ref deserializer) { + this.x = reader.read(int); + reader.readLiteral(" "); + this.y = reader.read(int); + reader.readNewline(); } - proc readThis(r: fileReader(?)) throws { - x = r.read(int); - r.readLiteral(" "); - y = r.read(int); - r.readNewline(); + override proc deserialize(reader, ref deserializer) throws { + x = reader.read(int); + reader.readLiteral(" "); + y = reader.read(int); + reader.readNewline(); } - proc writeThis(w: fileWriter(?)) throws { - w.write(x); - w.writeLiteral(" "); - w.write(y); - w.writeNewline(); + override proc serialize(writer, ref serializer) throws { + writer.write(x); + writer.writeLiteral(" "); + writer.write(y); + writer.writeNewline(); } } diff --git a/test/io/ferguson/recordeof.chpl b/test/io/ferguson/recordeof.chpl index 6a082ec77290..d12d07a13e24 100644 --- a/test/io/ferguson/recordeof.chpl +++ b/test/io/ferguson/recordeof.chpl @@ -3,9 +3,9 @@ use IO; record MyRecord { var i: int; proc init(i: int = 0) { this.i = i; } - proc init(f: fileReader(?)) throws { + proc init(reader, ref deserializer) throws { this.init(); - this.i = f.readln(int); + deserialize(reader, deserializer); } } @@ -16,14 +16,14 @@ config const debug = true; // Note that fileName not exist or have no contents var f = open(fileName, ioMode.cwr); -proc ref MyRecord.readThis(r: fileReader(?)) throws { - i = r.read(int); - r.readNewline(); +proc ref MyRecord.deserialize(reader, ref deserializer) throws { + i = reader.read(int); + reader.readNewline(); } -proc MyRecord.writeThis(w: fileWriter(?)) throws { - w.write(i); - w.writeNewline(); +proc MyRecord.serialize(writer, ref serializer) throws { + writer.write(i); + writer.writeNewline(); } { diff --git a/test/io/recordio.chpl b/test/io/recordio.chpl index 0bc08e45a21c..4585e918f5d6 100644 --- a/test/io/recordio.chpl +++ b/test/io/recordio.chpl @@ -88,22 +88,22 @@ var B: [0..#3] MyRecord; - the compiler will generate readThis/writeThis for you if you don't provide one */ -proc ref MyRecord.readThis(fr: fileReader(?)) throws { - i = fr.read(int); - fr.readLiteral("\t"); - r = fr.read(real); - fr.readLiteral("\t"); - s = fr.read(string); - fr.readLiteral("\n"); +proc ref MyRecord.deserialize(reader, ref deserializer) throws { + i = reader.read(int); + reader.readLiteral("\t"); + r = reader.read(real); + reader.readLiteral("\t"); + s = reader.read(string); + reader.readLiteral("\n"); } -proc MyRecord.writeThis(fw: fileWriter(?)) throws { - fw.write(i); - fw.writeLiteral("\t"); - fw.write(r); - fw.writeLiteral("\t"); - fw.write(s); - fw.writeLiteral("\n"); +proc MyRecord.serialize(writer, ref serializer) throws { + writer.write(i); + writer.writeLiteral("\t"); + writer.write(r); + writer.writeLiteral("\t"); + writer.write(s); + writer.writeLiteral("\n"); } proc MyRecord.init(i: int = 0, r: real = 0.0, s: string = "") { diff --git a/test/io/serializers/basic-types.big.good b/test/io/serializers/basic-types.big.good index 2a0e94affc1b..822e8a907556 100644 --- a/test/io/serializers/basic-types.big.good +++ b/test/io/serializers/basic-types.big.good @@ -214,4 +214,16 @@ SUCCESS ------------- SUCCESS ================================= + +===== set(int(64),false) ===== +===== writing: ===== +{5, 7, 8, 1, 4, 6, 2, 10, 9, 3} +-------------------- +000000000000000a0000000000000005000000000000000700000000000000080000000000000001000000000000000400000000000000060000000000000002000000000000000a00000000000000090000000000000003 +==================== +--- read: --- +{5, 7, 8, 1, 4, 6, 2, 10, 9, 3} +------------- +SUCCESS +============================== ALL SUCCESS diff --git a/test/io/serializers/basic-types.chpl b/test/io/serializers/basic-types.chpl index bfe860d4d4c3..46daf76fb5f1 100644 --- a/test/io/serializers/basic-types.chpl +++ b/test/io/serializers/basic-types.chpl @@ -2,6 +2,7 @@ use IO; use List; use Types; +use List, Set; use JSON; use FormatHelper; @@ -179,6 +180,10 @@ proc main() { test(x); delete x; + var s : set(int); + for i in 1..10 do s.add(i); + test(s); + if failures.size > 0 { writeln("FAILURES:"); for f in failures do diff --git a/test/io/serializers/basic-types.default.good b/test/io/serializers/basic-types.default.good index 9329bdacfb77..e04612e941d2 100644 --- a/test/io/serializers/basic-types.default.good +++ b/test/io/serializers/basic-types.default.good @@ -214,4 +214,16 @@ SUCCESS ------------- SUCCESS ================================= + +===== set(int(64),false) ===== +===== writing: ===== +{5, 7, 8, 1, 4, 6, 2, 10, 9, 3} +-------------------- +{5, 7, 8, 1, 4, 6, 2, 10, 9, 3} +==================== +--- read: --- +{5, 7, 8, 1, 4, 6, 2, 10, 9, 3} +------------- +SUCCESS +============================== ALL SUCCESS diff --git a/test/io/serializers/basic-types.json.good b/test/io/serializers/basic-types.json.good index 6171709b6fa2..68de4b8499c3 100644 --- a/test/io/serializers/basic-types.json.good +++ b/test/io/serializers/basic-types.json.good @@ -214,4 +214,16 @@ SUCCESS ------------- SUCCESS ================================= + +===== set(int(64),false) ===== +===== writing: ===== +{5, 7, 8, 1, 4, 6, 2, 10, 9, 3} +-------------------- +[5, 7, 8, 1, 4, 6, 2, 10, 9, 3] +==================== +--- read: --- +{5, 7, 8, 1, 4, 6, 2, 10, 9, 3} +------------- +SUCCESS +============================== ALL SUCCESS diff --git a/test/io/serializers/basic-types.little.good b/test/io/serializers/basic-types.little.good index 0c3cbe23ddee..eacae94a9b26 100644 --- a/test/io/serializers/basic-types.little.good +++ b/test/io/serializers/basic-types.little.good @@ -214,4 +214,16 @@ SUCCESS ------------- SUCCESS ================================= + +===== set(int(64),false) ===== +===== writing: ===== +{5, 7, 8, 1, 4, 6, 2, 10, 9, 3} +-------------------- +0a0000000000000005000000000000000700000000000000080000000000000001000000000000000400000000000000060000000000000002000000000000000a0000000000000009000000000000000300000000000000 +==================== +--- read: --- +{5, 7, 8, 1, 4, 6, 2, 10, 9, 3} +------------- +SUCCESS +============================== ALL SUCCESS diff --git a/test/io/serializers/basic-types.syntax.good b/test/io/serializers/basic-types.syntax.good index ed9980f792a1..9be3f88e027c 100644 --- a/test/io/serializers/basic-types.syntax.good +++ b/test/io/serializers/basic-types.syntax.good @@ -214,4 +214,16 @@ new borrowed SimpleChild(x = 5, y = 4.200000e+01) ------------- SUCCESS ================================= + +===== set(int(64),false) ===== +===== writing: ===== +{5, 7, 8, 1, 4, 6, 2, 10, 9, 3} +-------------------- +[5, 7, 8, 1, 4, 6, 2, 10, 9, 3] +==================== +--- read: --- +{5, 7, 8, 1, 4, 6, 2, 10, 9, 3} +------------- +SUCCESS +============================== ALL SUCCESS diff --git a/test/io/serializers/deserialize-by-ref.chpl b/test/io/serializers/deserialize-by-ref.chpl index 7fc87dc4b380..f098d6966bbe 100644 --- a/test/io/serializers/deserialize-by-ref.chpl +++ b/test/io/serializers/deserialize-by-ref.chpl @@ -5,6 +5,13 @@ record A { var x: int; var b: B; + proc serialize(writer, ref serializer) throws { + var ser = serializer.startRecord(writer, "A", 2); + ser.writeField("x", x); + ser.writeField("b", b); + ser.endRecord(); + } + proc ref deserialize(reader: fileReader(?), ref deserializer: reader.deserializerType) { writeln("IN A.deserialize"); var des = deserializer.startRecord(reader, "A"); @@ -35,6 +42,12 @@ record A { record B { var t: (int, real); + proc serialize(writer, ref serializer) throws { + var ser = serializer.startRecord(writer, "B", 1); + ser.writeField("t", t); + ser.endRecord(); + } + proc ref deserialize(reader: fileReader(?), ref deserializer: reader.deserializerType) { writeln("IN B.deserialize"); var des = deserializer.startRecord(reader, "B"); diff --git a/test/io/serializers/partial.A-init.good b/test/io/serializers/partial.A-init.good new file mode 100644 index 000000000000..f0f0db9141ec --- /dev/null +++ b/test/io/serializers/partial.A-init.good @@ -0,0 +1 @@ +$CHPL_HOME/modules/standard/IO.chpl:nnnn: error: unresolved call 'A.init(reader=fileReader(false,defaultDeserializer), deserializer=defaultDeserializer)' diff --git a/test/io/serializers/partial.chpl b/test/io/serializers/partial.chpl new file mode 100644 index 000000000000..2f4116d29ec0 --- /dev/null +++ b/test/io/serializers/partial.chpl @@ -0,0 +1,89 @@ + +use IO, Reflection; + +enum Variants { A, B, C, D } +enum Modes { Write, Read, Init } + +config param variant : Variants = Variants.A; +config param mode : Modes = Modes.Write; + +// Presence of normal, non-deserializing initializer should not disable +// generation of serialize/deserialize. +record A { + var x : int; + + proc init(x : int = 0) { + this.x = x; + } +} + +// Should disable generation of 'deserialize' and deserializing 'init' +record B { + var x : int; + + proc serialize(writer, ref serializer) throws { + ChapelIO.serializeDefaultImpl(writer, serializer, this); + } +} + +// Should disable generation of 'serialize' and 'deserialize' +record C { + var x : int; + + proc init(x : int = 0) { + this.x = x; + } + proc init(reader, ref deserializer) { + init this; + ChapelIO.deserializeDefaultImpl(reader, deserializer, this); + } +} + +// Should disable generation of 'serialize' and deserializing 'init' +record D { + var x : int; + + proc ref deserialize(reader, ref deserializer) throws { + ChapelIO.deserializeDefaultImpl(reader, deserializer, this); + } +} + +proc getType() type { + select variant { + when Variants.A do return A; + when Variants.B do return B; + when Variants.C do return C; + when Variants.D do return D; + otherwise do return nothing; + } +} + +proc doWrite(f, val) { + f.writer().write(val); +} + +proc doDeserialize(f, val) { + f.writer().write("(x = ", val.x, ")"); + var x : val.type; + f.reader().read(x); + assert(x.x == 10); +} + +proc doInit(f, val) { + f.writer().write("(x = ", val.x, ")"); + var x = f.reader().read(val.type); + assert(x.x == 10); +} + +proc main() { + var f = openMemFile(); + + var val : getType(); + val.x = 10; + + select mode { + when Modes.Write do doWrite(f, val); + when Modes.Read do doDeserialize(f, val); + when Modes.Init do doInit(f, val); + } +} diff --git a/test/io/serializers/partial.compopts b/test/io/serializers/partial.compopts new file mode 100644 index 000000000000..c429c7d9e492 --- /dev/null +++ b/test/io/serializers/partial.compopts @@ -0,0 +1,12 @@ +-svariant=Variants.A -smode=Modes.Write +-svariant=Variants.A -smode=Modes.Read +-svariant=Variants.A -smode=Modes.Init # partial.A-init.good +-svariant=Variants.B -smode=Modes.Write +-svariant=Variants.B -smode=Modes.Read # partial.no-des.good +-svariant=Variants.B -smode=Modes.Init # partial.noinit.good +-svariant=Variants.C -smode=Modes.Write # partial.noser.good +-svariant=Variants.C -smode=Modes.Read # partial.no-des.good +-svariant=Variants.C -smode=Modes.Init +-svariant=Variants.D -smode=Modes.Write # partial.noser.good +-svariant=Variants.D -smode=Modes.Read +-svariant=Variants.D -smode=Modes.Init # partial.noinit.good diff --git a/test/io/serializers/partial.good b/test/io/serializers/partial.good new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test/io/serializers/partial.no-des.good b/test/io/serializers/partial.no-des.good new file mode 100644 index 000000000000..bc15dc1fb1c1 --- /dev/null +++ b/test/io/serializers/partial.no-des.good @@ -0,0 +1 @@ +$CHPL_HOME/modules/standard/IO.chpl:nnnn: error: 'deserialize' methods are not compiler-generated when a type has a user-defined 'serialize' method. diff --git a/test/io/serializers/partial.noinit.good b/test/io/serializers/partial.noinit.good new file mode 100644 index 000000000000..f2db88464b37 --- /dev/null +++ b/test/io/serializers/partial.noinit.good @@ -0,0 +1 @@ +$CHPL_HOME/modules/standard/IO.chpl:nnnn: error: Initializers called by IO for deserialization are not compiler-generated when a user-defined 'serialize' or 'deserialize' method exists diff --git a/test/io/serializers/partial.noser.good b/test/io/serializers/partial.noser.good new file mode 100644 index 000000000000..2f905e0287ec --- /dev/null +++ b/test/io/serializers/partial.noser.good @@ -0,0 +1 @@ +$CHPL_HOME/modules/standard/IO.chpl:nnnn: error: 'serialize' methods are not compiler-generated when a type has a user-defined 'deserialize' method. diff --git a/test/io/serializers/partial.prediff b/test/io/serializers/partial.prediff new file mode 100755 index 000000000000..3df988456e15 --- /dev/null +++ b/test/io/serializers/partial.prediff @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# Ignore line numbers in modules. + +sed '\|CHPL_HOME/modules|s/:[0-9]*:/:nnnn:/' $2 > $2.tmp +mv $2.tmp $2 + +OUTPUT=$(grep "error: " $2) +if [ "$OUTPUT" ]; then + echo $OUTPUT > $2.tmp + mv $2.tmp $2 +fi + diff --git a/test/io/serializers/reader-init.chpl b/test/io/serializers/reader-init.chpl index f24462786198..3b31ae65fdaa 100644 --- a/test/io/serializers/reader-init.chpl +++ b/test/io/serializers/reader-init.chpl @@ -22,6 +22,10 @@ record R { return this.x == other.x && this.y == other.y; } + + proc serialize(writer, ref serializer) throws { + ChapelIO.serializeDefaultImpl(writer, serializer, this); + } } record G { @@ -50,6 +54,10 @@ record G { return this.x == other.x && this.y == other.y; } + + proc serialize(writer, ref serializer) throws { + ChapelIO.serializeDefaultImpl(writer, serializer, this); + } } class Parent { diff --git a/test/io/serializers/with-readThis.readThis.good b/test/io/serializers/with-readThis.readThis.good index 7344f9ea8f14..47a0f991f876 100644 --- a/test/io/serializers/with-readThis.readThis.good +++ b/test/io/serializers/with-readThis.readThis.good @@ -1,2 +1,3 @@ +with-readThis.chpl:7: warning: 'readThis' is deprecated. Please use 'deserialize' methods instead. in readThis (x = 5) diff --git a/test/io/serializers/with-readThis.without.good b/test/io/serializers/with-readThis.without.good index 1a7a02325ca1..61e07865bdb9 100644 --- a/test/io/serializers/with-readThis.without.good +++ b/test/io/serializers/with-readThis.without.good @@ -1,2 +1,3 @@ +with-readThis.chpl:7: warning: 'readThis' is deprecated. Please use 'deserialize' methods instead. Error: bad format: missing expected literal (while reading string literal "(" with path "unknown" offset 0) (x = 0) diff --git a/test/io/serializers/with-writeThis.chpl b/test/io/serializers/with-writeThis.chpl index 937034decf5d..8b7c6d619cae 100644 --- a/test/io/serializers/with-writeThis.chpl +++ b/test/io/serializers/with-writeThis.chpl @@ -4,8 +4,8 @@ use IO; record R { var x : int; - proc writeThis(f) { - f.write("writeThis: ", x); + proc writeThis(writer) { + writer.write("writeThis: ", x); } } diff --git a/test/io/serializers/with-writeThis.serialize.good b/test/io/serializers/with-writeThis.serialize.good index 084afcfdfe2f..999b88c0af85 100644 --- a/test/io/serializers/with-writeThis.serialize.good +++ b/test/io/serializers/with-writeThis.serialize.good @@ -1 +1,2 @@ +with-writeThis.chpl:7: warning: 'writeThis' is deprecated. Please use 'serialize' methods instead. (x = 5) diff --git a/test/io/serializers/with-writeThis.writeThis.good b/test/io/serializers/with-writeThis.writeThis.good index 088f9bb7769c..3102a07f3682 100644 --- a/test/io/serializers/with-writeThis.writeThis.good +++ b/test/io/serializers/with-writeThis.writeThis.good @@ -1 +1,2 @@ +with-writeThis.chpl:7: warning: 'writeThis' is deprecated. Please use 'serialize' methods instead. writeThis: 5 diff --git a/test/io/vass/writeThis-on.chpl b/test/io/vass/writeThis-on.chpl index eb8792550c19..8255d0c71dd3 100644 --- a/test/io/vass/writeThis-on.chpl +++ b/test/io/vass/writeThis-on.chpl @@ -2,7 +2,7 @@ class C { const home = here.id; - override proc writeThis(f) throws { f.write("here=", here.id, " home=", home); } + override proc serialize(writer, ref serializer) throws { writer.write("here=", here.id, " home=", home); } } for l in Locales do on l { diff --git a/test/library/draft/DataFrames/DataFrames.chpl b/test/library/draft/DataFrames/DataFrames.chpl index 763efa5a4d8f..eeaeba70577f 100644 --- a/test/library/draft/DataFrames/DataFrames.chpl +++ b/test/library/draft/DataFrames/DataFrames.chpl @@ -60,8 +60,8 @@ module DataFrames { } @chpldoc.nodoc - override proc writeThis(f) throws { - halt("cannot writeThis on generic Index"); + override proc serialize(writer, ref serializer) throws { + halt("cannot serialize on generic Index"); } iter these(type idxType) { @@ -270,18 +270,18 @@ module DataFrames { } override - proc writeThis(f) throws { + proc serialize(writer, ref serializer) throws { var idxWidth = writeIdxWidth() + 1; for space in 1..idxWidth do - f.write(" "); + writer.write(" "); for idx in this { - f.write("\n"); + writer.write("\n"); // TODO: clean up to simple cast after bugfix var idxStr = idx: string; - f.write(idxStr); + writer.write(idxStr); for space in 1..idxWidth-idxStr.size do - f.write(" "); + writer.write(" "); } } @@ -703,20 +703,20 @@ module DataFrames { } override - proc writeThis(f) throws { + proc serialize(writer, ref serializer) throws { if idx { - idx!.writeThis(f, _to_unmanaged(this)); + idx!.writeThis(writer, _to_unmanaged(this)); } else { for (v, (i, d)) in this._items() { - f.write(i:string + " "); + writer.write(i:string + " "); if v then - f.write(d); + writer.write(d); else - f.write("None"); - f.write("\n"); + writer.write("None"); + writer.write("\n"); } } - f.write("dtype: " + eltType:string); + writer.write("dtype: " + eltType:string); } @chpldoc.nodoc @@ -825,9 +825,9 @@ module DataFrames { } override - proc writeThis(f) throws { + proc serialize(writer, ref serializer) throws { if idx { - idx!.writeThis(f, _to_unmanaged(this)); + idx!.writeThis(writer, _to_unmanaged(this)); } else { var n = nrows(); var nStr = n: string; @@ -835,22 +835,22 @@ module DataFrames { const labelsSorted = labels.sorted(); for space in 1..idxWidth do - f.write(" "); + writer.write(" "); for lab in labelsSorted { - f.write(lab + " "); + writer.write(lab + " "); } for i in 0..#n { - f.write("\n"); + writer.write("\n"); var iStr = i: string; - f.write(iStr); + writer.write(iStr); for space in 1..idxWidth-iStr.size do - f.write(" "); + writer.write(" "); for lab in labelsSorted { const ser = columns[lab]; - ser!.writeElemNoIndex(f, i, lab.size); - f.write(" "); + ser!.writeElemNoIndex(writer, i, lab.size); + writer.write(" "); } } } diff --git a/test/library/draft/DistributedList/DistributedList.chpl b/test/library/draft/DistributedList/DistributedList.chpl index dc6805c67fe1..165f205caac3 100644 --- a/test/library/draft/DistributedList/DistributedList.chpl +++ b/test/library/draft/DistributedList/DistributedList.chpl @@ -516,13 +516,13 @@ module DistributedList { } } - proc writeThis(fr) throws { - fr.write('['); + proc serialize(writer, ref serializer) throws { + writer.write('['); for (elt, i) in zip(this.these(), 0..) { - if i > 0 then fr.write(", "); - fr.write(elt); + if i > 0 then writer.write(", "); + writer.write(elt); } - fr.write(']'); + writer.write(']'); } // TODO: readThis()? diff --git a/test/library/draft/DistributedMap/DistributedMap.chpl b/test/library/draft/DistributedMap/DistributedMap.chpl index 7dc201df2a96..aa77875a3947 100644 --- a/test/library/draft/DistributedMap/DistributedMap.chpl +++ b/test/library/draft/DistributedMap/DistributedMap.chpl @@ -39,12 +39,12 @@ record distributedMap { this.init(impl); } - proc readThis(ch) throws { + proc ref deserialize(reader, ref deserializer) throws { compilerError("Reading a distributedMap is not supported"); } - proc writeThis(ch) throws { - _value.write(ch); + proc serialize(writer, ref serializer) throws { + _value.write(writer); } } // record distributedMap diff --git a/test/library/draft/DistributedMap/v2/DistributedMap.chpl b/test/library/draft/DistributedMap/v2/DistributedMap.chpl index ca23f2f8274f..7d6726e82b62 100644 --- a/test/library/draft/DistributedMap/v2/DistributedMap.chpl +++ b/test/library/draft/DistributedMap/v2/DistributedMap.chpl @@ -50,7 +50,7 @@ module DistributedMap { proc init(type keyType, type valType, reader: fileReader(?), ref deserializer) throws { this.init(keyType, valType); - readThis(reader); + deserialize(reader, deserializer); } proc clear() { @@ -58,12 +58,12 @@ module DistributedMap { m!.mapClear(); } - proc readThis(ch: fileReader(?)) throws { - m!.readThis(ch); + proc ref deserialize(reader, ref deserializer) throws { + m!.deserialize(reader, deserializer); } - proc writeThis(ch: fileWriter(?)) throws { - m!.writeThis(ch); + proc serialize(writer, ref serializer) throws { + m!.serialize(writer, serializer); } } @@ -399,12 +399,13 @@ module DistributedMap { } } - proc init(type keyType, type valType, r: fileReader(?)) { + proc init(type keyType, type valType, + reader: fileReader(?), ref deserializer) { this.init(keyType, valType); - readThis(r); + deserialize(reader, deserializer); } - // TODO: if writeThis encodes the locale hash, this should react to it + // TODO: if serialize encodes the locale hash, this should react to it // Right now, it's not easy to call read with a distributedMap as a type // argument because of how we store the hasher object. /* @@ -416,7 +417,8 @@ module DistributedMap { :arg ch: A fileReader to read from. */ - proc readThis(ch: fileReader(?)) throws { + override proc deserialize(reader, ref deserializer) throws { + var ch = reader; for i in locDom { locks[i].lock(); } @@ -463,7 +465,8 @@ module DistributedMap { :arg ch: A fileWriter to write to. */ - proc writeThis(ch: fileWriter(?)) throws { + override proc serialize(writer, ref serializer) throws { + var ch = writer; for i in locDom { locks[i].lock(); } diff --git a/test/library/draft/DistributedMap/v3/DistributedMap.chpl b/test/library/draft/DistributedMap/v3/DistributedMap.chpl index 6492a983b8f0..4c5eed8618e9 100644 --- a/test/library/draft/DistributedMap/v3/DistributedMap.chpl +++ b/test/library/draft/DistributedMap/v3/DistributedMap.chpl @@ -33,8 +33,8 @@ module DistributedMap { this.instance!.clear(); } - proc writeThis(fr) throws { - this.instance!.writeThis(fr); + proc serialize(writer, ref serializer) throws { + this.instance!.serialize(writer, serializer); } } @@ -122,7 +122,8 @@ module DistributedMap { compilerError("unimplemented"); } - proc writeThis(fr) throws { + override proc serialize(writer, ref serializer) throws { + var fr = writer; for locIdx in this.locDom { on this.targetLocales[locIdx] { fr.write("[", this.targetLocales[locIdx], ": "); diff --git a/test/library/draft/Vector/Vector.chpl b/test/library/draft/Vector/Vector.chpl index c928294d2fbb..6b912df7130c 100644 --- a/test/library/draft/Vector/Vector.chpl +++ b/test/library/draft/Vector/Vector.chpl @@ -1158,16 +1158,13 @@ module Vector { } @chpldoc.nodoc - proc readThis(ch: fileReader(?)) throws { + proc deserialize(reader, ref deserializer) throws { compilerError("Reading a Vector is not supported"); } - /* - Write the contents of this vector to a fileWriter. - - :arg ch: A fileWriter to write to. - */ - proc writeThis(ch: fileWriter(?)) throws { + @chpldoc.nodoc + proc serialize(writer, ref serializer) throws { + var ch = writer; _enter(); ch.write("["); diff --git a/test/library/packages/HDF5/htable/HTable.chpl b/test/library/packages/HDF5/htable/HTable.chpl index 8dafac873da4..4a0b4412307b 100644 --- a/test/library/packages/HDF5/htable/HTable.chpl +++ b/test/library/packages/HDF5/htable/HTable.chpl @@ -237,9 +237,9 @@ module HTable { /* Debugging routine, prints a human-readable version of how the routine has parsed the field. */ - proc writeThis(f) { + proc serialize(writer, ref serializer) { for ii in 1..nFields { - f.writeln(names[ii]:string, " ", offsets[ii]); + writer.writeln(names[ii]:string, " ", offsets[ii]); } } diff --git a/test/library/packages/LAPACK/TestHelpers.chpl b/test/library/packages/LAPACK/TestHelpers.chpl index 67123780d3f2..12c6ae9feddf 100644 --- a/test/library/packages/LAPACK/TestHelpers.chpl +++ b/test/library/packages/LAPACK/TestHelpers.chpl @@ -75,12 +75,12 @@ module TestHelpers { this.matrix_domain = {1..#rows,1..#columns}; this.epsilon = error; - this.complete(); + init this; this.populateFromArray( input_array, input_row_order ); } - proc init( matrix: borrowed LAPACK_Matrix, type data_type = matrix.data_type ){ + proc init( matrix: borrowed LAPACK_Matrix(?), type data_type = matrix.data_type ){ this.data_type = data_type; this.row_major = matrix.row_major; this.rows = matrix.rows; @@ -88,7 +88,7 @@ module TestHelpers { this.data_domain = matrix.data_domain; this.matrix_domain = matrix.matrix_domain; - this.complete(); + init this; for idx in data_domain do this.data[idx] = matrix.data[idx]; this.epsilon = matrix.epsilon; @@ -190,8 +190,8 @@ module TestHelpers { } // Not using type queries to work around issue #13721 - operator LAPACK_Matrix.*(A: borrowed LAPACK_Matrix, - B: borrowed LAPACK_Matrix): owned LAPACK_Matrix(A.data_type) { + operator LAPACK_Matrix.*(A: borrowed LAPACK_Matrix(?), + B: borrowed LAPACK_Matrix(?)): owned LAPACK_Matrix(A.data_type) { if A.data_type != B.data_type then compilerError("data_type mismatch in *"); @@ -212,8 +212,8 @@ module TestHelpers { return retmatrix; } - operator LAPACK_Matrix.==(A: borrowed LAPACK_Matrix, - B: borrowed LAPACK_Matrix ): bool { + operator LAPACK_Matrix.==(A: borrowed LAPACK_Matrix(?), + B: borrowed LAPACK_Matrix(?) ): bool { if A.data_type != B.data_type then compilerError("data_type mismatch in =="); diff --git a/test/library/packages/Sort/correctness/keyPartEnding.chpl b/test/library/packages/Sort/correctness/keyPartEnding.chpl index f80cb359f49a..aadad91c12a3 100644 --- a/test/library/packages/Sort/correctness/keyPartEnding.chpl +++ b/test/library/packages/Sort/correctness/keyPartEnding.chpl @@ -7,10 +7,10 @@ record TwoRepeated { var second:int; var nSecond:int; - proc writeThis(ch) throws { + proc serialize(writer, ref serializer) throws { var a = (first:string)*nFirst; var b = (second:string)*nSecond; - ch.write(a, b); + writer.write(a, b); } } diff --git a/test/library/packages/SortedSet/general/kth/noDefaultValue.good b/test/library/packages/SortedSet/general/kth/noDefaultValue.good index b14810109219..d50fa4f1745e 100644 --- a/test/library/packages/SortedSet/general/kth/noDefaultValue.good +++ b/test/library/packages/SortedSet/general/kth/noDefaultValue.good @@ -1,4 +1,4 @@ -$CHPL_HOME/modules/packages/SortedSet.chpl:276: In method 'kth': -$CHPL_HOME/modules/packages/SortedSet.chpl:277: error: kth is not available on types that can't be +$CHPL_HOME/modules/packages/SortedSet.chpl:281: In method 'kth': +$CHPL_HOME/modules/packages/SortedSet.chpl:282: error: kth is not available on types that can't be default-initialized, here: shared Foo noDefaultValue.chpl:30: called as (sortedSet(shared Foo,false,DefaultComparator)).kth(k: int(64)) diff --git a/test/library/packages/Yaml/basic-types.chpl b/test/library/packages/Yaml/basic-types.chpl index cebd449087ab..d4444190fcb0 100644 --- a/test/library/packages/Yaml/basic-types.chpl +++ b/test/library/packages/Yaml/basic-types.chpl @@ -71,16 +71,12 @@ record CustomizedRecord { r.readLiteral(">"); } - proc writeThis(f) throws { - f.writeLiteral("<"); - f.write(x); - f.writeLiteral(", "); - f.write(y); - f.writeLiteral(">"); - } - - proc serialize(writer: fileWriter(?), ref serializer) { - writeThis(writer); + proc serialize(writer, ref serializer) throws { + writer.writeLiteral("<"); + writer.write(x); + writer.writeLiteral(", "); + writer.write(y); + writer.writeLiteral(">"); } } diff --git a/test/library/packages/Yaml/deserializeByRef.chpl b/test/library/packages/Yaml/deserializeByRef.chpl index a540f670e9f2..cad65f1b6aa4 100644 --- a/test/library/packages/Yaml/deserializeByRef.chpl +++ b/test/library/packages/Yaml/deserializeByRef.chpl @@ -5,6 +5,10 @@ record A { var x: int; var b: B; + proc serialize(writer, ref serializer) throws { + ChapelIO.serializeDefaultImpl(writer, serializer, this); + } + proc ref deserialize(reader: fileReader(?), ref deserializer: reader.deserializerType) { writeln("IN A.deserialize"); var des = deserializer.startRecord(reader, "A"); @@ -35,6 +39,10 @@ record A { record B { var t: (int, real); + proc serialize(writer, ref serializer) throws { + ChapelIO.serializeDefaultImpl(writer, serializer, this); + } + proc ref deserialize(reader: fileReader(?), ref deserializer: reader.deserializerType) { writeln("IN B.deserialize"); var des = deserializer.startRecord(reader, "B"); diff --git a/test/library/packages/canCompileNoLink/FFTWtest.compopts b/test/library/packages/canCompileNoLink/FFTWtest.compopts new file mode 100644 index 000000000000..dea20e009ab0 --- /dev/null +++ b/test/library/packages/canCompileNoLink/FFTWtest.compopts @@ -0,0 +1 @@ +-snewRangeLiteralType diff --git a/test/library/standard/GMP/studies/gmp-chudnovsky.chpl b/test/library/standard/GMP/studies/gmp-chudnovsky.chpl index de304f22c767..ed02861615e6 100644 --- a/test/library/standard/GMP/studies/gmp-chudnovsky.chpl +++ b/test/library/standard/GMP/studies/gmp-chudnovsky.chpl @@ -602,8 +602,8 @@ proc fg2 ref do return fgstack[top+1]; var progress = 0.0; /* -proc mpz_t.writeThis(f) throws { - var outfile = f: file; +proc mpz_t.serialize(writer, ref serializer) throws { + var outfile = writer: file; gmp_fprintf(outfile._fp, "%Zd", this); if (outfile) then } diff --git a/test/library/standard/IO/formatted/serde_specifier.chpl b/test/library/standard/IO/formatted/serde_specifier.chpl index 4e6d02b7eb56..292d0a91ffbb 100644 --- a/test/library/standard/IO/formatted/serde_specifier.chpl +++ b/test/library/standard/IO/formatted/serde_specifier.chpl @@ -3,14 +3,14 @@ use IO, IO.FormattedIO; record R { var x: int; - proc writeThis(fw: fileWriter(?)) throws { - fw.write("<", x, ">"); + proc serialize(writer, ref serializer) throws { + writer.write("<", x, ">"); } - proc ref readThis(fr: fileReader(?)) throws { - fr.readLiteral("<"); - this.x = fr.read(int); - fr.readLiteral(">"); + proc ref deserialize(reader, ref deserializer) throws { + reader.readLiteral("<"); + this.x = reader.read(int); + reader.readLiteral(">"); } } diff --git a/test/library/standard/IO/readBinary/COMPOPTS b/test/library/standard/IO/readBinary/COMPOPTS index 9bd1b424a7d8..c9005f45e0f0 100644 --- a/test/library/standard/IO/readBinary/COMPOPTS +++ b/test/library/standard/IO/readBinary/COMPOPTS @@ -1 +1 @@ --sReadBinaryArrayReturnInt=true +-sReadBinaryArrayReturnInt=true -snewRangeLiteralType diff --git a/test/library/standard/IO/readTo/readUpToType.chpl b/test/library/standard/IO/readTo/readUpToType.chpl index 3b349b7dbb45..e7d7c3f0bee8 100644 --- a/test/library/standard/IO/readTo/readUpToType.chpl +++ b/test/library/standard/IO/readTo/readUpToType.chpl @@ -5,12 +5,12 @@ record xyType { var y: real; } -proc ref xyType.readThis(fr) throws { - fr.matchLiteral("|"); - this.x = fr.read(int); - fr.matchLiteral(","); - this.y = fr.read(real); - fr.matchLiteral("|"); +proc ref xyType.deserialize(reader, ref deserializer) throws { + reader.matchLiteral("|"); + this.x = reader.read(int); + reader.matchLiteral(","); + this.y = reader.read(real); + reader.matchLiteral("|"); } proc xyType.init(x = 0, y = 0.0) { @@ -20,15 +20,11 @@ proc xyType.init(x = 0, y = 0.0) { proc xyType.init(reader, ref deserializer) { this.init(); - readThis(reader); + deserialize(reader, deserializer); } -proc xyType.deserialize(reader, ref deserializer) throws { - readThis(reader); -} - -proc xyType.writeThis(fw) throws { - fw.write("(", this.x, ", ", this.y, ")"); +proc xyType.serialize(writer, ref serializer) throws { + writer.write("(", this.x, ", ", this.y, ")"); } var r = openReader("xy.txt"); diff --git a/test/library/standard/Map/types/ClassWithMapWithRecord.chpl b/test/library/standard/Map/types/ClassWithMapWithRecord.chpl index 44fe9f4c30bb..b91fafd879fd 100644 --- a/test/library/standard/Map/types/ClassWithMapWithRecord.chpl +++ b/test/library/standard/Map/types/ClassWithMapWithRecord.chpl @@ -120,26 +120,26 @@ record map { } } - proc writeThis(fw: fileWriter(?)) throws { + proc serialize(writer, ref serializer) throws { var first = true; - fw.writeLiteral("{"); + writer.writeLiteral("{"); for slot in table.allSlots() { if table.isSlotFull(slot) { if first { first = false; } else { - fw.writeLiteral(", "); + writer.writeLiteral(", "); } ref tabEntry = table.table[slot]; ref key = tabEntry.key; ref val = tabEntry.val; - fw.write(key); - fw.writeLiteral(": "); - fw.write(val); + writer.write(key); + writer.writeLiteral(": "); + writer.write(val); } } - fw.writeLiteral("}"); + writer.writeLiteral("}"); } class KeyNotFoundError : Error { diff --git a/test/library/standard/Math/testcases_gcd.chpl b/test/library/standard/Math/testcases_gcd.chpl index 0be17c694c43..aeca23b81d31 100644 --- a/test/library/standard/Math/testcases_gcd.chpl +++ b/test/library/standard/Math/testcases_gcd.chpl @@ -17,3 +17,143 @@ writeln(gcd(0,8)); writeln(gcd(4,0)); writeln(gcd(0,0)); + +writeln(gcd(2,8).type : string); + +writeln("int(32) tests"); + +writeln(gcd(4: int(32), 8: int(32))); + +writeln(gcd(2: int(32), 8: int(32))); + +writeln(gcd(3: int(32), 8: int(32))); + +writeln(gcd(5: int(32), 11: int(32))); + +writeln(gcd(4: int(32), -8: int(32))); + +writeln(gcd(-4: int(32), -8: int(32))); + +writeln(gcd(0: int(32), 8: int(32))); + +writeln(gcd(4: int(32), 0: int(32))); + +writeln(gcd(0: int(32), 0: int(32))); + +writeln(gcd(2: int(32), 8: int(32)).type : string); + +writeln("int(16) tests"); + +writeln(gcd(4: int(16), 8: int(16))); + +writeln(gcd(2: int(16), 8: int(16))); + +writeln(gcd(3: int(16), 8: int(16))); + +writeln(gcd(5: int(16), 11: int(16))); + +writeln(gcd(4: int(16), -8: int(16))); + +writeln(gcd(-4: int(16), -8: int(16))); + +writeln(gcd(0: int(16), 8: int(16))); + +writeln(gcd(4: int(16), 0: int(16))); + +writeln(gcd(0: int(16), 0: int(16))); + +writeln(gcd(2: int(16), 8: int(16)).type : string); + +writeln("int(8) tests"); + +writeln(gcd(4: int(8), 8: int(8))); + +writeln(gcd(2: int(8), 8: int(8))); + +writeln(gcd(3: int(8), 8: int(8))); + +writeln(gcd(5: int(8), 11: int(8))); + +writeln(gcd(4: int(8), -8: int(8))); + +writeln(gcd(-4: int(8), -8: int(8))); + +writeln(gcd(0: int(8), 8: int(8))); + +writeln(gcd(4: int(8), 0: int(8))); + +writeln(gcd(0: int(8), 0: int(8))); + +writeln(gcd(2: int(8), 8: int(8)).type : string); + +writeln("uint(64) tests"); + +writeln(gcd(4: uint(64), 8: uint(64))); + +writeln(gcd(2: uint(64), 8: uint(64))); + +writeln(gcd(3: uint(64), 8: uint(64))); + +writeln(gcd(5: uint(64), 11: uint(64))); + +writeln(gcd(0: uint(64), 8: uint(64))); + +writeln(gcd(4: uint(64), 0: uint(64))); + +writeln(gcd(0: uint(64), 0: uint(64))); + +writeln(gcd(2: uint(64), 8: uint(64)).type : string); + +writeln("uint(32) tests"); + +writeln(gcd(4: uint(32), 8: uint(32))); + +writeln(gcd(2: uint(32), 8: uint(32))); + +writeln(gcd(3: uint(32), 8: uint(32))); + +writeln(gcd(5: uint(32), 11: uint(32))); + +writeln(gcd(0: uint(32), 8: uint(32))); + +writeln(gcd(4: uint(32), 0: uint(32))); + +writeln(gcd(0: uint(32), 0: uint(32))); + +writeln(gcd(2: uint(32), 8: uint(32)).type : string); + +writeln("uint(16) tests"); + +writeln(gcd(4: uint(16), 8: uint(16))); + +writeln(gcd(2: uint(16), 8: uint(16))); + +writeln(gcd(3: uint(16), 8: uint(16))); + +writeln(gcd(5: uint(16), 11: uint(16))); + +writeln(gcd(0: uint(16), 8: uint(16))); + +writeln(gcd(4: uint(16), 0: uint(16))); + +writeln(gcd(0: uint(16), 0: uint(16))); + +writeln(gcd(2: uint(16), 8: uint(16)).type : string); + +writeln("uint(8) tests"); + +writeln(gcd(4: uint(8), 8: uint(8))); + +writeln(gcd(2: uint(8), 8: uint(8))); + +writeln(gcd(3: uint(8), 8: uint(8))); + +writeln(gcd(5: uint(8), 11: uint(8))); + +writeln(gcd(0: uint(8), 8: uint(8))); + +writeln(gcd(4: uint(8), 0: uint(8))); + +writeln(gcd(0: uint(8), 0: uint(8))); + +writeln(gcd(2: uint(8), 8: uint(8)).type : string); diff --git a/test/library/standard/Math/testcases_gcd.good b/test/library/standard/Math/testcases_gcd.good index 2fe02ce99bad..1212074ec5df 100644 --- a/test/library/standard/Math/testcases_gcd.good +++ b/test/library/standard/Math/testcases_gcd.good @@ -7,3 +7,73 @@ 8 4 0 +int(64) +int(32) tests +4 +2 +1 +1 +4 +4 +8 +4 +0 +int(32) +int(16) tests +4 +2 +1 +1 +4 +4 +8 +4 +0 +int(16) +int(8) tests +4 +2 +1 +1 +4 +4 +8 +4 +0 +int(8) +uint(64) tests +4 +2 +1 +1 +8 +4 +0 +uint(64) +uint(32) tests +4 +2 +1 +1 +8 +4 +0 +uint(32) +uint(16) tests +4 +2 +1 +1 +8 +4 +0 +uint(16) +uint(8) tests +4 +2 +1 +1 +8 +4 +0 +uint(8) diff --git a/test/library/standard/MemMove/LowLevelBuffer.chpl b/test/library/standard/MemMove/LowLevelBuffer.chpl index d4d2e3a09030..309a739860f0 100644 --- a/test/library/standard/MemMove/LowLevelBuffer.chpl +++ b/test/library/standard/MemMove/LowLevelBuffer.chpl @@ -42,8 +42,8 @@ record buffer { } // A standard implementation probably shouldn't offer this. - proc writeThis(ch) { - for slot in this do ch.write(slot, " "); + proc serialize(writer, ref serializer) { + for slot in this do writer.write(slot, " "); } } diff --git a/test/library/standard/Random/stonea/fillRandomAssociative.good b/test/library/standard/Random/stonea/fillRandomAssociative.good index 17f9e13dceb2..3f6f88faa397 100644 --- a/test/library/standard/Random/stonea/fillRandomAssociative.good +++ b/test/library/standard/Random/stonea/fillRandomAssociative.good @@ -1,3 +1,3 @@ -$CHPL_HOME/modules/standard/Random.chpl:129: In function 'fillRandom': -$CHPL_HOME/modules/standard/Random.chpl:136: error: fillRandom does not support non-rectangular arrays +$CHPL_HOME/modules/standard/Random.chpl:130: In function 'fillRandom': +$CHPL_HOME/modules/standard/Random.chpl:137: error: fillRandom does not support non-rectangular arrays fillRandomAssociative.chpl:5: called as fillRandom(arr: [DefaultAssociativeDom(int(64),true)] real(64), seed: int(64), param algorithm = 1: RNG) diff --git a/test/library/standard/Random/stonea/permutationAssociative.good b/test/library/standard/Random/stonea/permutationAssociative.good index 0c828e407d06..95d2213c2aaf 100644 --- a/test/library/standard/Random/stonea/permutationAssociative.good +++ b/test/library/standard/Random/stonea/permutationAssociative.good @@ -1,3 +1,3 @@ -$CHPL_HOME/modules/standard/Random.chpl:213: In function 'permutation': -$CHPL_HOME/modules/standard/Random.chpl:221: error: permutation does not support non-rectangular arrays +$CHPL_HOME/modules/standard/Random.chpl:214: In function 'permutation': +$CHPL_HOME/modules/standard/Random.chpl:222: error: permutation does not support non-rectangular arrays permutationAssociative.chpl:5: called as permutation(arr: [DefaultAssociativeDom(int(64),true)] real(64), seed: int(64), param algorithm = 1: RNG) diff --git a/test/library/standard/Random/stonea/shuffleAssociative.good b/test/library/standard/Random/stonea/shuffleAssociative.good index 39f0af7caca1..73f5cfdb9bd8 100644 --- a/test/library/standard/Random/stonea/shuffleAssociative.good +++ b/test/library/standard/Random/stonea/shuffleAssociative.good @@ -1,3 +1,3 @@ -$CHPL_HOME/modules/standard/Random.chpl:190: In function 'shuffle': -$CHPL_HOME/modules/standard/Random.chpl:199: error: shuffle does not support non-rectangular arrays +$CHPL_HOME/modules/standard/Random.chpl:191: In function 'shuffle': +$CHPL_HOME/modules/standard/Random.chpl:200: error: shuffle does not support non-rectangular arrays shuffleAssociative.chpl:5: called as shuffle(arr: [DefaultAssociativeDom(int(64),true)] real(64), seed: int(64), param algorithm = 1: RNG) diff --git a/test/memory/benmcd/tryCopy.chpl b/test/memory/benmcd/tryCopy.chpl new file mode 100644 index 000000000000..9adfe0dcb2b2 --- /dev/null +++ b/test/memory/benmcd/tryCopy.chpl @@ -0,0 +1,11 @@ +use BlockDist; + +var a: [1..10] int = 10; +var c = blockDist.createArray(0..10, int); +c = 199; + +var b = a.tryCopy(); +var d = c.tryCopy(); + +writeln(b); +writeln(d); diff --git a/test/memory/benmcd/tryCopy.good b/test/memory/benmcd/tryCopy.good new file mode 100644 index 000000000000..9c8ce47ab48e --- /dev/null +++ b/test/memory/benmcd/tryCopy.good @@ -0,0 +1,2 @@ +10 10 10 10 10 10 10 10 10 10 +199 199 199 199 199 199 199 199 199 199 199 diff --git a/test/memory/benmcd/tryCreateArrayIterable.chpl b/test/memory/benmcd/tryCreateArrayIterable.chpl new file mode 100644 index 000000000000..6e357215a043 --- /dev/null +++ b/test/memory/benmcd/tryCreateArrayIterable.chpl @@ -0,0 +1,7 @@ +var dom: domain(1) = {1..10}; + +var arr = dom.tryCreateArray(int, [i in dom] i*2); +writeln(arr); + +arr = dom.tryCreateArray(int, 42); +writeln(arr); diff --git a/test/memory/benmcd/tryCreateArrayIterable.good b/test/memory/benmcd/tryCreateArrayIterable.good new file mode 100644 index 000000000000..0abcef627927 --- /dev/null +++ b/test/memory/benmcd/tryCreateArrayIterable.good @@ -0,0 +1,2 @@ +2 4 6 8 10 12 14 16 18 20 +42 42 42 42 42 42 42 42 42 42 diff --git a/test/memory/benmcd/tryCreateArrayTypeChange.chpl b/test/memory/benmcd/tryCreateArrayTypeChange.chpl new file mode 100644 index 000000000000..3ada16370327 --- /dev/null +++ b/test/memory/benmcd/tryCreateArrayTypeChange.chpl @@ -0,0 +1,8 @@ +var arr: [1..10] bool = false; + +var switched = arr.domain.tryCreateArray(int, arr); + +writeln(arr); +writeln(switched); +writeln(arr.type:string); +writeln(switched.type:string); diff --git a/test/memory/benmcd/tryCreateArrayTypeChange.good b/test/memory/benmcd/tryCreateArrayTypeChange.good new file mode 100644 index 000000000000..d71b28aa3562 --- /dev/null +++ b/test/memory/benmcd/tryCreateArrayTypeChange.good @@ -0,0 +1,4 @@ +false false false false false false false false false false +0 0 0 0 0 0 0 0 0 0 +[domain(1,int(64),one)] bool +[domain(1,int(64),one)] int(64) diff --git a/test/modules/diten/returnClassDiffModule5.chpl b/test/modules/diten/returnClassDiffModule5.chpl index 101a5aa03a15..9088a69995fb 100644 --- a/test/modules/diten/returnClassDiffModule5.chpl +++ b/test/modules/diten/returnClassDiffModule5.chpl @@ -8,9 +8,9 @@ module M1 { proc foo() { return a+b; } - override proc writeThis(f) throws { - f.writeln("How does this get found?"); - f.write("{a = ", a, ", b = ", b, "}"); + override proc serialize(writer, ref serializer) throws { + writer.writeln("How does this get found?"); + writer.write("{a = ", a, ", b = ", b, "}"); } } } diff --git a/test/multilocale/bharshbarg/onStmtInIntent.chpl b/test/multilocale/bharshbarg/onStmtInIntent.chpl index e81b120bd416..13e6b24f7e10 100644 --- a/test/multilocale/bharshbarg/onStmtInIntent.chpl +++ b/test/multilocale/bharshbarg/onStmtInIntent.chpl @@ -43,7 +43,7 @@ record R { Communication.put(x, src, home.id, numBytes(int)); } - proc writeThis(writer) { + proc serialize(writer, ref serializer) { writer.write("{", get(), "}"); } } diff --git a/test/multilocale/bradc/needMultiLocales/writeThisUsingOn.bad b/test/multilocale/bradc/needMultiLocales/writeThisUsingOn.bad index a88128d53465..042048af1d2f 100644 --- a/test/multilocale/bradc/needMultiLocales/writeThisUsingOn.bad +++ b/test/multilocale/bradc/needMultiLocales/writeThisUsingOn.bad @@ -1 +1 @@ -C is: 0writeThisUsingOn.chpl:47: error: halt reached - Timed out +writeThisUsingOn.chpl:47: error: halt reached - Timed out diff --git a/test/multilocale/bradc/needMultiLocales/writeThisUsingOn.chpl b/test/multilocale/bradc/needMultiLocales/writeThisUsingOn.chpl index 206d95be029e..a42ce60f838f 100644 --- a/test/multilocale/bradc/needMultiLocales/writeThisUsingOn.chpl +++ b/test/multilocale/bradc/needMultiLocales/writeThisUsingOn.chpl @@ -3,9 +3,9 @@ use Time; class LocC { var id: int; - proc writeThis(x) throws { + override proc serialize(writer, ref serializer) throws { on this { - x.write(id); + writer.write(id); } } } @@ -21,12 +21,12 @@ class C { } } - proc writeThis(x) throws { + override proc serialize(writer, ref serializer) throws { for loc in LocaleSpace { on Locales(loc) { if loc != 0 then - write(" "); - write(locCs(loc)); + writer.write(" "); + writer.write(locCs(loc)); } } } diff --git a/test/multilocale/deitz/needMultiLocales/privateLimitedDistributedArrayClass1.chpl b/test/multilocale/deitz/needMultiLocales/privateLimitedDistributedArrayClass1.chpl index f1bd96eb0d5a..924065831429 100644 --- a/test/multilocale/deitz/needMultiLocales/privateLimitedDistributedArrayClass1.chpl +++ b/test/multilocale/deitz/needMultiLocales/privateLimitedDistributedArrayClass1.chpl @@ -18,11 +18,11 @@ proc DistributedArray.this(i: int) ref { } } -proc DistributedArray.writeThis(W) throws { +override proc DistributedArray.serialize(writer, ref serializer) throws { for loc in Locales { - W.write(if loc == here then data else others[loc.id]!.data); + writer.write(if loc == here then data else others[loc.id]!.data); if loc.id != numLocales-1 then - W.write(" "); + writer.write(" "); } } diff --git a/test/multilocale/deitz/needMultiLocales/privateLimitedDistributedArrayClass2.chpl b/test/multilocale/deitz/needMultiLocales/privateLimitedDistributedArrayClass2.chpl index 084795eee789..eb75c1226d41 100644 --- a/test/multilocale/deitz/needMultiLocales/privateLimitedDistributedArrayClass2.chpl +++ b/test/multilocale/deitz/needMultiLocales/privateLimitedDistributedArrayClass2.chpl @@ -20,11 +20,11 @@ proc DistributedArray.this(i: int) ref { } } -proc DistributedArray.writeThis(W) throws { +override proc DistributedArray.serialize(writer, ref serializer) throws { for loc in Locales { - W.write(if loc == here then data else others[loc.id]!.data); + writer.write(if loc == here then data else others[loc.id]!.data); if loc.id != numLocales-1 then - W.write(" "); + writer.write(" "); } } diff --git a/test/multilocale/diten/oneOrMoreLocales/1DBlockDistributedJacobi.chpl b/test/multilocale/diten/oneOrMoreLocales/1DBlockDistributedJacobi.chpl index ea0c9165c946..1ee0b0715e56 100644 --- a/test/multilocale/diten/oneOrMoreLocales/1DBlockDistributedJacobi.chpl +++ b/test/multilocale/diten/oneOrMoreLocales/1DBlockDistributedJacobi.chpl @@ -73,10 +73,10 @@ class DistribArray { } } - proc writeThis(w) throws { + override proc serialize(writer, ref serializer) throws { on Locales(0) { for i in 0..arrSize-1 { - w.writeln(element(i)); + writer.writeln(element(i)); } } } diff --git a/test/parallel/taskPar/sungeun/private.chpl b/test/parallel/taskPar/sungeun/private.chpl index 566eb1f8aa20..7474782cd508 100644 --- a/test/parallel/taskPar/sungeun/private.chpl +++ b/test/parallel/taskPar/sungeun/private.chpl @@ -20,8 +20,8 @@ record taskPrivateData { } // need our version of writeThis so we can print the sync field - proc writeThis(f) throws { - f.write("(", tid.readXX(), ": ", x, " ", y, ")"); + proc serialize(writer, ref serializer) throws { + writer.write("(", tid.readXX(), ": ", x, " ", y, ")"); } }; diff --git a/test/param/diten/paramForDiffTypes3.compopts b/test/param/diten/paramForDiffTypes3.compopts new file mode 100644 index 000000000000..65d7d8313615 --- /dev/null +++ b/test/param/diten/paramForDiffTypes3.compopts @@ -0,0 +1,2 @@ + # paramForDiffTypes3.old.good + -snewRangeLiteralType # paramForDiffTypes3.good diff --git a/test/param/diten/paramForDiffTypes3.old.good b/test/param/diten/paramForDiffTypes3.old.good new file mode 100644 index 000000000000..9009ad180c26 --- /dev/null +++ b/test/param/diten/paramForDiffTypes3.old.good @@ -0,0 +1,12 @@ +paramForDiffTypes3.chpl:6: warning: the idxType of this range literal 1..2 with the low bound of the type int(32) and the high bound of the type int(64) is currently int(32). In a future release it will be switched to int(64). To switch to this new typing and turn off this warning, compile with -snewRangeLiteralType. +paramForDiffTypes3.chpl:11: warning: the idxType of this range literal 1..2 with the low bound of the type int(32) and the high bound of the type int(64) is currently int(32). In a future release it will be switched to int(64). To switch to this new typing and turn off this warning, compile with -snewRangeLiteralType. +paramForDiffTypes3.chpl:11: warning: the idxType of this range literal 1..2 with the low bound of the type int(32) and the high bound of the type int(64) is currently int(32). In a future release it will be switched to int(64). To switch to this new typing and turn off this warning, compile with -snewRangeLiteralType. +paramForDiffTypes3.chpl:15: warning: the idxType of this range literal 1..2 with the low bound of the type int(32) and the high bound of the type int(64) is currently int(32). In a future release it will be switched to int(64). To switch to this new typing and turn off this warning, compile with -snewRangeLiteralType. +r 1..2 : range(int(32),both,one) +t 1..2 : range(int(64),both,one) +p (1, int(32)) +p (2, int(32)) +v (1, int(32)) +v (2, int(32)) +u (1, int(64)) +u (2, int(64)) diff --git a/test/parsing/errors/exceptOnlyInvalidExpr-detailed.good b/test/parsing/errors/exceptOnlyInvalidExpr-detailed.good index 33941c4b894a..43c2b6873916 100644 --- a/test/parsing/errors/exceptOnlyInvalidExpr-detailed.good +++ b/test/parsing/errors/exceptOnlyInvalidExpr-detailed.good @@ -3,5 +3,6 @@ In the 'except' list here: | 1 | use OS except "not a symbol"; + | ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ | diff --git a/test/release/examples/primers/fileIO.chpl b/test/release/examples/primers/fileIO.chpl index 06490846f576..0f43bbdb284e 100644 --- a/test/release/examples/primers/fileIO.chpl +++ b/test/release/examples/primers/fileIO.chpl @@ -310,11 +310,11 @@ if example == 0 || example == 6 { } record MyThing { - proc writeThis(w) throws { - w.writeln("This should be a chunk: {"); - w.writeln(" a"); - w.writeln(" b"); - w.writeln("}"); + proc serialize(writer, ref serializer) throws { + writer.writeln("This should be a chunk: {"); + writer.writeln(" a"); + writer.writeln(" b"); + writer.writeln("}"); } } diff --git a/test/release/examples/primers/iterators.chpl b/test/release/examples/primers/iterators.chpl index 176b43252525..db2ceb9aa946 100644 --- a/test/release/examples/primers/iterators.chpl +++ b/test/release/examples/primers/iterators.chpl @@ -171,7 +171,7 @@ var tree = new Tree( "a", // This method uses the postorder iterator to print out each node. // It uses the "first" flag to avoid printing a leading space. // -proc Tree.writeThis(x) +override proc Tree.serialize(writer, ref serializer) { var first = true; @@ -179,9 +179,9 @@ proc Tree.writeThis(x) if first then first = false; else - x.write(" "); + writer.write(" "); - x.write(node.data); + writer.write(node.data); } } diff --git a/test/release/examples/primers/procedures.chpl b/test/release/examples/primers/procedures.chpl index 95c91cf428df..8352b90ae2f3 100644 --- a/test/release/examples/primers/procedures.chpl +++ b/test/release/examples/primers/procedures.chpl @@ -92,16 +92,16 @@ operator Point.+(p1: Point, p2: Point) } // -// We can also overload the ``writeThis()`` routine called by writeln. +// We can also overload the ``serialize`` routine called by writeln. // -proc Point.writeThis(w) throws +proc Point.serialize(writer, ref serializer) throws { // Writes it out as a coordinate pair. - w.write("("); - w.write(this.x); - w.write(", "); - w.write(this.y); - w.write(")"); + writer.write("("); + writer.write(this.x); + writer.write(", "); + writer.write(this.y); + writer.write(")"); } writeln("Using operator overloading"); diff --git a/test/release/examples/primers/specialMethods.chpl b/test/release/examples/primers/specialMethods.chpl index e660d77c0029..ef2fa7d17f07 100644 --- a/test/release/examples/primers/specialMethods.chpl +++ b/test/release/examples/primers/specialMethods.chpl @@ -148,17 +148,18 @@ myD += myR; ---------- */ -// The ``writeThis`` method defines how to write an instance of R to a +// The ``serialize`` method defines how to write an instance of R to a // channel. We'll write the ``vals`` tuple between asterisks. See section -// :ref:`readThis-writeThis` for more information on the ``writeThis`` and -// ``readThis`` methods. +// :ref:`serialize-deserialize` for more information on the ``serialize`` and +// ``deserialize`` methods. use IO; // required for file operations config const filename = "tempfile.txt"; -proc R.writeThis(ch: fileWriter(?)) throws { - ch.write("*", vals, "*"); +proc R.serialize(writer: fileWriter(?), + ref serializer: writer.serializerType) throws { + writer.write("*", vals, "*"); } { @@ -169,13 +170,14 @@ proc R.writeThis(ch: fileWriter(?)) throws { ch.writeln(r); } -// The ``readThis`` method defines how to read an instance of R from a +// The ``deserialize`` method defines how to read an instance of R from a // channel. We'll read the ``vals`` tuple between asterisks like how it // was written above. -proc ref R.readThis(ch: fileReader(?)) throws { - ch.readLiteral("*"); - ch.read(vals); - ch.readLiteral("*"); +proc ref R.deserialize(reader: fileReader(?), + ref deserializer: reader.deserializerType) throws { + reader.readLiteral("*"); + reader.read(vals); + reader.readLiteral("*"); } { diff --git a/test/studies/590o/alaska/graph.chpl b/test/studies/590o/alaska/graph.chpl index 2792be52505f..d82b5ae35669 100644 --- a/test/studies/590o/alaska/graph.chpl +++ b/test/studies/590o/alaska/graph.chpl @@ -22,16 +22,16 @@ class Node { var pred : unmanaged Node? = nil; var disc,fini : int = -1; - proc writeThis(w){ - w.write("{",name,"}"); + override proc serialize(writer, ref serializer){ + writer.write("{",name,"}"); } - proc writeFancy(w){ - w.write("{",name," : ",color); - if(pred != nil) then w.write("^",pred.name); - if(disc >= 0) then w.write(" ",disc); - if(fini >= 0) then w.write(",",fini); - w.write("}"); + proc writeFancy(writer){ + writer.write("{",name," : ",color); + if(pred != nil) then writer.write("^",pred.name); + if(disc >= 0) then writer.write(" ",disc); + if(fini >= 0) then writer.write(",",fini); + writer.write("}"); } } @@ -49,7 +49,7 @@ class Edge { var dst: unmanaged Node; var reversed: bool = false; var kind: edgeKind = edgeKind.GRAPH; - proc writeThis(w){ + override proc serialize(writer, ref serializer){ var ec:string; select(kind) { when edgeKind.GRAPH do ec = "--->"; @@ -65,7 +65,7 @@ class Edge { } otherwise halt("invalid edge kind",kind); } - w.write(src,ec,dst); + writer.write(src,ec,dst); } iter these() { if( src != nil) then yield src; @@ -146,8 +146,8 @@ proc Edge.read(infile: file){ */ class UndirectedEdge : Edge { - proc writeThis(w){ - w.write(src," -- ",dst); + override proc serialize(writer, ref serializer){ + writer.write(src," -- ",dst); } } diff --git a/test/studies/adventOfCode/2021/bradc/futures/day18-bug.bad b/test/studies/adventOfCode/2021/bradc/futures/day18-bug.bad index 848a456d77c6..d827df972971 100644 --- a/test/studies/adventOfCode/2021/bradc/futures/day18-bug.bad +++ b/test/studies/adventOfCode/2021/bradc/futures/day18-bug.bad @@ -1,6 +1,8 @@ day18-bug.chpl:11: In initializer: day18-bug.chpl:11: warning: need '(?)' on the type 'Node' of the formal 'l' because this type is generic day18-bug.chpl:11: warning: need '(?)' on the type 'Node' of the formal 'r' because this type is generic +day18-bug.chpl:23: warning: please use '?' when declaring a routine with a generic return type +day18-bug.chpl:23: note: for example with 'Node(?)' day18-bug.chpl:26: warning: please use '?' when declaring a variable with generic type day18-bug.chpl:26: note: for example with 'Node(?)' day18-bug.chpl:26: warning: please use '?' when declaring a variable with generic type diff --git a/test/studies/adventOfCode/2021/bradc/futures/day18-bug2.bad b/test/studies/adventOfCode/2021/bradc/futures/day18-bug2.bad index 71abcfc2980c..c9628b8ec1c5 100644 --- a/test/studies/adventOfCode/2021/bradc/futures/day18-bug2.bad +++ b/test/studies/adventOfCode/2021/bradc/futures/day18-bug2.bad @@ -1,6 +1,8 @@ day18-bug2.chpl:11: In initializer: day18-bug2.chpl:11: warning: need '(?)' on the type 'Node' of the formal 'l' because this type is generic day18-bug2.chpl:11: warning: need '(?)' on the type 'Node' of the formal 'r' because this type is generic +day18-bug2.chpl:23: warning: please use '?' when declaring a routine with a generic return type +day18-bug2.chpl:23: note: for example with 'Node(?)' day18-bug2.chpl:26: warning: please use '?' when declaring a variable with generic type day18-bug2.chpl:26: note: for example with 'Node(?)' $CHPL_HOME/modules/internal/OwnedObject.chpl:57: In initializer: diff --git a/test/studies/amr/lib/level/Level_def.chpl b/test/studies/amr/lib/level/Level_def.chpl index 40ecabace88e..92b8caee17a7 100644 --- a/test/studies/amr/lib/level/Level_def.chpl +++ b/test/studies/amr/lib/level/Level_def.chpl @@ -155,7 +155,7 @@ class Level { // sensible. Mainly for testing and debugging. //----------------------------------------------------------- - proc writeThis(w) throws { + proc serialize(writer, ref serializer) throws { writeln("Level bounds: ", x_low, " ", x_high); writeln("Number of cells: ", n_cells); writeln("Number of ghost cells: ", n_ghost_cells); diff --git a/test/studies/bale/toposort/toposort.chpl b/test/studies/bale/toposort/toposort.chpl index 823e29c51a7a..ff8b9719ed77 100644 --- a/test/studies/bale/toposort/toposort.chpl +++ b/test/studies/bale/toposort/toposort.chpl @@ -459,23 +459,23 @@ class PermutationMap { // TODO leader follower iterator - override proc writeThis( f ){ + override proc serialize(writer, ref serializer){ const maxVal = max( (max reduce rowMap), (max reduce columnMap) ) : string; const minVal = min( (min reduce rowMap), (min reduce columnMap) ) : string; const padding = max( maxVal.size, minVal.size ); const formatString = "%%%nn -> %%%nn".format( max(2,padding), padding ); const inSpace = max(padding-2,0); - f.writeln("Row map"); - for i in 0..#inSpace do f.write(" "); - f.write("in -> out"); + writer.writeln("Row map"); + for i in 0..#inSpace do writer.write(" "); + writer.write("in -> out"); for i in rowDom { - f.writeln(formatString.format( i, rowMap[i] )); + writer.writeln(formatString.format( i, rowMap[i] )); } - f.writeln("Column map"); - for i in 0..#inSpace do f.write(" "); - f.writeln("in -> out"); + writer.writeln("Column map"); + for i in 0..#inSpace do writer.write(" "); + writer.writeln("in -> out"); for i in columnDom { - f.write(formatString.format( i, columnMap[i] )); + writer.write(formatString.format( i, columnMap[i] )); } } diff --git a/test/studies/comd/elegant/arrayOfStructs/util/AccumStencilDist.chpl b/test/studies/comd/elegant/arrayOfStructs/util/AccumStencilDist.chpl index 5eb52e69b22a..e8b93a565cb9 100644 --- a/test/studies/comd/elegant/arrayOfStructs/util/AccumStencilDist.chpl +++ b/test/studies/comd/elegant/arrayOfStructs/util/AccumStencilDist.chpl @@ -380,15 +380,15 @@ override proc AccumStencil.dsiNewRectangularDom(param rank: int, type idxType, // // output distribution // -proc AccumStencil.writeThis(x) throws { - x.writeln("AccumStencil"); - x.writeln("-------"); - x.writeln("distributes: ", boundingBox); - x.writeln("across locales: ", targetLocales); - x.writeln("indexed via: ", targetLocDom); - x.writeln("resulting in: "); +proc AccumStencil.serialize(writer, ref serializer) throws { + writer.writeln("AccumStencil"); + writer.writeln("-------"); + writer.writeln("distributes: ", boundingBox); + writer.writeln("across locales: ", targetLocales); + writer.writeln("indexed via: ", targetLocDom); + writer.writeln("resulting in: "); for locid in targetLocDom do - x.writeln(" [", locid, "] locale ", locDist(locid).locale.id, " owns chunk: ", locDist(locid).myChunk); + writer.writeln(" [", locid, "] locale ", locDist(locid).locale.id, " owns chunk: ", locDist(locid).myChunk); } proc AccumStencil.dsiIndexToLocale(ind: idxType) where rank == 1 { diff --git a/test/studies/hpcc/common/bradc/BradsBlock1D.chpl b/test/studies/hpcc/common/bradc/BradsBlock1D.chpl index fedbe78b772e..245c02e85ede 100644 --- a/test/studies/hpcc/common/bradc/BradsBlock1D.chpl +++ b/test/studies/hpcc/common/bradc/BradsBlock1D.chpl @@ -214,8 +214,8 @@ class Block1DDom { // // the print method for the domain // - proc writeThis(x) throws { - x.write(whole); + override proc serialize(writer, ref serializer) throws { + writer.write(whole); } // @@ -276,8 +276,8 @@ class LocBlock1DDom { // // how to write out this locale's indices // - proc writeThis(x) throws { - x.write(myBlock); + override proc serialize(writer, ref serializer) throws { + writer.write(myBlock); } // @@ -373,7 +373,7 @@ class Block1DArr { // // how to print out the whole array, sequentially // - proc writeThis(x) throws { + override proc serialize(writer, ref serializer) throws { var first = true; for loc in dom.dist.targetLocs { // May want to do something like the following: @@ -383,9 +383,9 @@ class Block1DArr { if (first) { first = false; } else { - x.write(" "); + writer.write(" "); } - x.write(locArr(loc)); + writer.write(locArr(loc)); } // } stdout.flush(); @@ -445,11 +445,11 @@ class LocBlock1DArr { // // prints out this locale's piece of the array // - proc writeThis(x) throws { + override proc serialize(writer, ref serializer) throws { // May want to do something like the following: // on loc { // but it causes deadlock -- see writeThisUsingOn.chpl - x.write(myElems); + writer.write(myElems); } // diff --git a/test/studies/hpcc/common/bradc/BradsBlock1DPar-deitzditen.chpl b/test/studies/hpcc/common/bradc/BradsBlock1DPar-deitzditen.chpl index c383f01579fe..b64b99f47e29 100644 --- a/test/studies/hpcc/common/bradc/BradsBlock1DPar-deitzditen.chpl +++ b/test/studies/hpcc/common/bradc/BradsBlock1DPar-deitzditen.chpl @@ -249,8 +249,8 @@ class Block1DDom { // // the print method for the domain // - proc writeThis(x) throws { - x.write(whole); + proc serialize(writer, ref serializer) throws { + writer.write(whole); } // @@ -330,8 +330,8 @@ class LocBlock1DDom { // // how to write out this locale's indices // - proc writeThis(x) throws { - x.write(myBlock); + proc serialize(writer, ref serializer) throws { + writer.write(myBlock); } // @@ -444,7 +444,7 @@ class Block1DArr { // // how to print out the whole array, sequentially // - proc writeThis(x) throws { + proc serialize(writer, ref serializer) throws { var first = true; for loc in dom.dist.targetLocs { // May want to do something like the following: @@ -454,9 +454,9 @@ class Block1DArr { if (first) { first = false; } else { - x.write(" "); + writer.write(" "); } - x.write(locArr(loc)); + writer.write(locArr(loc)); } // } stdout.flush(); @@ -535,11 +535,11 @@ class LocBlock1DArr { // // prints out this locale's piece of the array // - proc writeThis(x) throws { + proc serialize(writer, ref serializer) throws { // May want to do something like the following: // on loc { // but it causes deadlock -- see writeThisUsingOn.chpl - x.write(myElems); + writer.write(myElems); } // diff --git a/test/studies/hpcc/common/bradc/BradsBlock1DPar-ideal.chpl b/test/studies/hpcc/common/bradc/BradsBlock1DPar-ideal.chpl index 71fac07bbac0..449221ad1e8c 100644 --- a/test/studies/hpcc/common/bradc/BradsBlock1DPar-ideal.chpl +++ b/test/studies/hpcc/common/bradc/BradsBlock1DPar-ideal.chpl @@ -112,15 +112,15 @@ class Block1DDist { // - proc writeThis(x) throws { - x.writeln("BradsBlock1DPar"); - x.writeln("---------------"); - x.writeln("distributes: ", boundingBox); - x.writeln("across locales: ", targetLocs); - x.writeln("indexed via: ", targetLocDom); - x.writeln("resulting in: "); + proc serialize(writer, ref serializer) throws { + writer.writeln("BradsBlock1DPar"); + writer.writeln("---------------"); + writer.writeln("distributes: ", boundingBox); + writer.writeln("across locales: ", targetLocs); + writer.writeln("indexed via: ", targetLocDom); + writer.writeln("resulting in: "); for locid in targetLocDom do - x.writeln(" [", locid, "] ", locDist(locid)); + writer.writeln(" [", locid, "] ", locDist(locid)); } @@ -211,8 +211,8 @@ class LocBlock1DDist { proc procToData(x, lo) return (lo + (x: lo.type) + (x:real != x:int:real)); - proc writeThis(x) throws { - x.write("locale ", loc.id, " owns chunk: ", myChunk); + proc serialize(writer, ref serializer) throws { + writer.write("locale ", loc.id, " owns chunk: ", myChunk); } } @@ -327,8 +327,8 @@ class Block1DDom { // // the print method for the domain // - proc writeThis(x) throws { - x.write(whole); + proc serialize(writer, ref serializer) throws { + writer.write(whole); } // @@ -408,8 +408,8 @@ class LocBlock1DDom { // // how to write out this locale's indices // - proc writeThis(x) throws { - x.write(myBlock); + proc serialize(writer, ref serializer) throws { + writer.write(myBlock); } // @@ -511,7 +511,7 @@ class Block1DArr { // // how to print out the whole array, sequentially // - proc writeThis(x) throws { + proc serialize(writer, ref serializer) throws { var first = true; for loc in dom.dist.targetLocDom { // May want to do something like the following: @@ -521,9 +521,9 @@ class Block1DArr { if (first) { first = false; } else { - x.write(" "); + writer.write(" "); } - x.write(locArr(loc)); + writer.write(locArr(loc)); } // } stdout.flush(); @@ -607,11 +607,11 @@ class LocBlock1DArr { // // prints out this locale's piece of the array // - proc writeThis(x) throws { + proc serialize(writer, ref serializer) throws { // May want to do something like the following: // on loc { // but it causes deadlock -- see writeThisUsingOn.chpl - x.write(myElems); + writer.write(myElems); } // diff --git a/test/studies/hpcc/common/bradc/BradsBlock1DPar.chpl b/test/studies/hpcc/common/bradc/BradsBlock1DPar.chpl index 3c55c4bae96b..7526019ee669 100644 --- a/test/studies/hpcc/common/bradc/BradsBlock1DPar.chpl +++ b/test/studies/hpcc/common/bradc/BradsBlock1DPar.chpl @@ -102,15 +102,15 @@ class Block1DDist { // // print out the distribution // - proc writeThis(x) throws { - x.writeln("BradsBlock1DPar"); - x.writeln("---------------"); - x.writeln("distributes: ", boundingBox); - x.writeln("across locales: ", targetLocs); - x.writeln("indexed via: ", targetLocDom); - x.writeln("resulting in: "); + override proc serialize(writer, ref serializer) throws { + writer.writeln("BradsBlock1DPar"); + writer.writeln("---------------"); + writer.writeln("distributes: ", boundingBox); + writer.writeln("across locales: ", targetLocs); + writer.writeln("indexed via: ", targetLocDom); + writer.writeln("resulting in: "); for locid in targetLocDom do - x.writeln(" [", locid, "] ", locDist(locid)); + writer.writeln(" [", locid, "] ", locDist(locid)); } // @@ -234,8 +234,8 @@ class LocBlock1DDist { // // print out the local distribution class // - proc writeThis(x) throws { - x.write("locale ", loc.id, " owns chunk: ", myChunk); + override proc serialize(writer, ref serializer) throws { + writer.write("locale ", loc.id, " owns chunk: ", myChunk); } } @@ -389,8 +389,8 @@ class Block1DDom { // // the print method for the domain // - proc writeThis(x) throws { - x.write(whole); + override proc serialize(writer, ref serializer) throws { + writer.write(whole); } // @@ -481,8 +481,8 @@ class LocBlock1DDom { // // how to write out this locale's indices // - proc writeThis(x) throws { - x.write(myBlock); + override proc serialize(writer, ref serializer) throws { + writer.write(myBlock); } @@ -605,7 +605,7 @@ class Block1DArr { // // how to print out the whole array, sequentially // - proc writeThis(x) throws { + override proc serialize(writer, ref serializer) throws { var first = true; for loc in dom.dist.targetLocDom { // May want to do something like the following: @@ -615,9 +615,9 @@ class Block1DArr { if (first) { first = false; } else { - x.write(" "); + writer.write(" "); } - x.write(locArr(loc)); + writer.write(locArr(loc)); } // } stdout.flush(); @@ -701,11 +701,11 @@ class LocBlock1DArr { // // prints out this locale's piece of the array // - proc writeThis(x) throws { + override proc serialize(writer, ref serializer) throws { // May want to do something like the following: // on loc { // but it causes deadlock -- see writeThisUsingOn.chpl - x.write(myElems); + writer.write(myElems); } // diff --git a/test/studies/ml/lib/Tensor.chpl b/test/studies/ml/lib/Tensor.chpl index b27a824df6d7..78fba6a83f78 100644 --- a/test/studies/ml/lib/Tensor.chpl +++ b/test/studies/ml/lib/Tensor.chpl @@ -248,7 +248,8 @@ module Tensor { } // Prints the tensor (only really works for rank 1 and 2) - proc writeThis(fw: IO.fileWriter(?)) throws { + proc serializer(writer: IO.fileWriter(?), ref serializer) throws { + const ref fw = writer; fw.write("tensor("); const shape = this.shape; var first: bool = true; diff --git a/test/studies/nqueens/nqueens-2-par.chpl b/test/studies/nqueens/nqueens-2-par.chpl index 5dbabb79622a..c7be631fba5f 100644 --- a/test/studies/nqueens/nqueens-2-par.chpl +++ b/test/studies/nqueens/nqueens-2-par.chpl @@ -187,27 +187,27 @@ proc Board.nextPlacementIsLegal(col: int): bool { // config var show1line: bool = true; -override proc Board.writeThis(f) throws { +override proc Board.serialize(writer, ref serializer) throws { if boardSize <= 0 { - f.write( taskNum, ": the board is empty"); + writer.write( taskNum, ": the board is empty"); return; } var notFilledMsg = ""; if lastfilled < boardSize then notFilledMsg = " row(s) "+ (lastfilled + 1):string + " to " + boardSize:string + " are not filled"; if show1line { - f.write( + writer.write( taskNum, ": ", [row in 1..lastfilled] (row, queencol(row)), notFilledMsg); } else { - for {1..boardSize} do f.write("-"); f.writeln(); + for {1..boardSize} do writer.write("-"); writer.writeln(); for row in 1..lastfilled { for col in 1..boardSize do - f.write(if queencol(row) == col then "*" else " "); - f.writeln(); + writer.write(if queencol(row) == col then "*" else " "); + writer.writeln(); } - if notFilledMsg != "" then f.writeln(notFilledMsg); - for {1..boardSize} do f.write("-"); + if notFilledMsg != "" then writer.writeln(notFilledMsg); + for {1..boardSize} do writer.write("-"); } } diff --git a/test/studies/nqueens/nqueens-2-seq.chpl b/test/studies/nqueens/nqueens-2-seq.chpl index 26a8c0892c69..f99eec7affec 100644 --- a/test/studies/nqueens/nqueens-2-seq.chpl +++ b/test/studies/nqueens/nqueens-2-seq.chpl @@ -142,26 +142,26 @@ proc Board.nextPlacementIsLegal(col: int): bool { // config var show1line: bool = true; -override proc Board.writeThis(f) throws { +override proc Board.serialize(writer, ref serializer) throws { if boardSize <= 0 { - f.write("the board is empty"); + writer.write("the board is empty"); return; } var notFilledMsg = ""; if lastfilled < boardSize then notFilledMsg = " row(s) "+ (lastfilled + 1):string + " to " + boardSize:string + " are not filled"; if show1line { - f.write( + writer.write( [row in 1..lastfilled] (row, queencol(row)), notFilledMsg); } else { - for {1..boardSize} do f.write("-"); f.writeln(); + for {1..boardSize} do writer.write("-"); writer.writeln(); for row in 1..lastfilled { for col in 1..boardSize do - f.write(if queencol(row) == col then "*" else " "); - f.writeln(); + writer.write(if queencol(row) == col then "*" else " "); + writer.writeln(); } - if notFilledMsg != "" then f.writeln(notFilledMsg); - for {1..boardSize} do f.write("-"); + if notFilledMsg != "" then writer.writeln(notFilledMsg); + for {1..boardSize} do writer.write("-"); } } diff --git a/test/studies/programs/linkedList.chpl b/test/studies/programs/linkedList.chpl index 3bb170e4aa8c..76241d3ea08a 100644 --- a/test/studies/programs/linkedList.chpl +++ b/test/studies/programs/linkedList.chpl @@ -140,14 +140,14 @@ class List { // Define the style of the output when a list is passed to the write or // writeln functions. The values will be written separated by spaces. // The argument 'w' is a writeable channel. - proc writeThis(w) throws { + override proc serialize(writer, ref serializer) throws { var first = true; for i in this do if first { - w.write(i); + writer.write(i); first = false; } else { - w.write(" ", i); + writer.write(" ", i); } } } diff --git a/test/studies/shootout/submitted/revcomp8.good b/test/studies/shootout/submitted/revcomp8.good index 3b062cb2d225..d2f64774a279 100644 --- a/test/studies/shootout/submitted/revcomp8.good +++ b/test/studies/shootout/submitted/revcomp8.good @@ -6,6 +6,8 @@ revcomp8.chpl:28: warning: openfd is deprecated, please use the file initializer revcomp8.chpl:28: warning: reader with a 'kind' argument is deprecated, please use Deserializers instead revcomp8.chpl:30: warning: openfd is deprecated, please use the file initializer with a 'c_int' argument instead revcomp8.chpl:30: warning: writer with a 'kind' argument is deprecated, please use Serializers instead +revcomp8.chpl:33: In function 'main': +revcomp8.chpl:35: warning: the idxType of this range literal 10..121 with the low bound of the type uint(8) and the high bound of the type int(64) is currently uint(8). In a future release it will be switched to int(64). To switch to this new typing and turn off this warning, compile with -snewRangeLiteralType. revcomp8.chpl:146: In function 'revcomp': revcomp8.chpl:155: warning: This cast from 'c_ptr(uint(8))' to 'c_ptr(uint(16))' casts a c_ptr to a pointer of non-equivalent, non-char element type, which can cause undefined behavior. revcomp8.chpl:156: warning: This cast from 'c_ptr(uint(8))' to 'c_ptr(uint(16))' casts a c_ptr to a pointer of non-equivalent, non-char element type, which can cause undefined behavior. diff --git a/test/studies/shootout/submitted/revcomp8.notest b/test/studies/shootout/submitted/revcomp8.notest deleted file mode 100644 index 0b667fda3864..000000000000 --- a/test/studies/shootout/submitted/revcomp8.notest +++ /dev/null @@ -1,11 +0,0 @@ -The following now creates an int(64) range, where a uint(16) range is desired: - const chars = eol..::template __run<__FetchT>(__handle, __args...)); } +#if CUDA_VERSION < 12000 // texture<> objects get magically converted into a texture reference. However, // there's no way to convert them to cudaTextureObject_t on C++ level. So, we // cheat a bit and use inline assembly to do it. It costs us an extra register @@ -713,6 +714,7 @@ __tex_fetch(__DataT *, __RetT *__ptr, __tex_fetch_v4<__op>::template __run<__FetchT>( __tex_handle_to_obj(__handle), __args...)); } +#endif // CUDA_VERSION } // namespace __cuda_tex } // namespace #pragma pop_macro("__ASM_OUT") diff --git a/tools/mason/MasonExample.chpl b/tools/mason/MasonExample.chpl index ad5fb3bffda6..a3c3558b5069 100644 --- a/tools/mason/MasonExample.chpl +++ b/tools/mason/MasonExample.chpl @@ -120,7 +120,7 @@ private proc getBuildInfo(projectHome: string, skipUpdate: bool) { // retrieves compopts and execopts for each example. // returns assoc array of -> <(compopts, execopts)> -private proc getExampleOptions(toml: Toml(?), exampleNames: list(string)) { +private proc getExampleOptions(toml: Toml, exampleNames: list(string)) { var exampleOptions = new map(string, (string, string)); for example in exampleNames { @@ -293,7 +293,7 @@ private proc runExampleBinary(projectHome: string, exampleName: string, } } -private proc getExamples(toml: Toml(?), projectHome: string) { +private proc getExamples(toml: Toml, projectHome: string) { var exampleNames: list(string); const examplePath = joinPath(projectHome, "example"); diff --git a/tools/mason/MasonExternal.chpl b/tools/mason/MasonExternal.chpl index 4a472c4dc49a..5e511a9d8482 100644 --- a/tools/mason/MasonExternal.chpl +++ b/tools/mason/MasonExternal.chpl @@ -412,7 +412,7 @@ private proc editCompilers() { /* Given a toml of external dependencies returns the dependencies in a toml in lock file format */ -proc getExternalPackages(exDeps: Toml(?)) /* [domain(string)] shared Toml? */ { +proc getExternalPackages(exDeps: Toml) /* [domain(string)] shared Toml? */ { var exDom: domain(string); var exDepTree: [exDom] shared Toml?; diff --git a/tools/mason/MasonSystem.chpl b/tools/mason/MasonSystem.chpl index 542068dccf34..9a2eeb2ca81c 100644 --- a/tools/mason/MasonSystem.chpl +++ b/tools/mason/MasonSystem.chpl @@ -233,7 +233,7 @@ proc getPkgInfo(pkgName: string, version: string) throws { /* Given a toml of external dependencies returns the dependencies in a toml */ -proc getPCDeps(exDeps: Toml(?)) { +proc getPCDeps(exDeps: Toml) { var exDom: domain(string); var exDepTree: [exDom] shared Toml?; diff --git a/tools/mason/MasonUpdate.chpl b/tools/mason/MasonUpdate.chpl index d3f909affc83..f15257a90b48 100644 --- a/tools/mason/MasonUpdate.chpl +++ b/tools/mason/MasonUpdate.chpl @@ -215,7 +215,7 @@ proc chplVersionError(brick:borrowed Toml) { from the Mason.toml. Starts at the root of the project and continues down dep tree recursively until each dep is recorded */ -private proc createDepTree(root: Toml(?)) { +private proc createDepTree(root: Toml) { var dp: domain(string); var dps: [dp] shared Toml?; var depTree = new shared Toml(dps); @@ -284,7 +284,7 @@ private proc createDepTree(root: Toml(?)) { return depTree; } -private proc createDepTrees(depTree: Toml(?), ref deps: list(shared Toml), name: string) : shared Toml { +private proc createDepTrees(depTree: Toml, ref deps: list(shared Toml), name: string) : shared Toml { var depList: list(shared Toml?); while deps.size > 0 { var dep = deps[0]; @@ -326,7 +326,7 @@ private proc createDepTrees(depTree: Toml(?), ref deps: list(shared Toml), name: return depTree; } -private proc addGitDeps(depTree: Toml(?), ref gitDeps) { +private proc addGitDeps(depTree: Toml, ref gitDeps) { //val url branch revision for key in gitDeps { if !depTree.pathExists(key[0]) { @@ -459,7 +459,7 @@ private proc retrieveGitDep(name: string, branch: string) { /* Checks if a dependency has deps; if so, the dependencies are returned as a (string, Toml) */ -private proc getDependencies(tomlTbl: Toml(?)) { +private proc getDependencies(tomlTbl: Toml) { var depsD: domain(1); var deps: list((string, shared Toml?)); for k in tomlTbl.A.keys() { @@ -472,7 +472,7 @@ private proc getDependencies(tomlTbl: Toml(?)) { return deps; } -private proc getGitDeps(tomlTbl: Toml(?)) { +private proc getGitDeps(tomlTbl: Toml) { var gitDeps: list((string, string, shared Toml?)); for k in tomlTbl["dependencies"]!.A.keys() { for (a, d) in allFields(tomlTbl["dependencies"]![k]!) { diff --git a/tools/mason/MasonUtils.chpl b/tools/mason/MasonUtils.chpl index 713ce80e5d3f..5c12660473db 100644 --- a/tools/mason/MasonUtils.chpl +++ b/tools/mason/MasonUtils.chpl @@ -769,7 +769,7 @@ proc InitProject(dirName, packageName, vcs, show, /* Iterator to collect fields from a toml TODO custom fields returned */ -iter allFields(tomlTbl: Toml(?)) { +iter allFields(tomlTbl: Toml) { for (k,v) in zip(tomlTbl.A.keys(), tomlTbl.A.values()) { if v!.tag == fieldtag.fieldToml then continue; diff --git a/util/chplenv/chpl_gpu.py b/util/chplenv/chpl_gpu.py index 3c8c09ebb64a..37cb898865ec 100644 --- a/util/chplenv/chpl_gpu.py +++ b/util/chplenv/chpl_gpu.py @@ -200,7 +200,7 @@ def _validate_cuda_version_impl(): """Check that the installed CUDA version is >= MIN_REQ_VERSION and < MAX_REQ_VERSION""" MIN_REQ_VERSION = "7" - MAX_REQ_VERSION = "12" + MAX_REQ_VERSION = "13" chpl_cuda_path = get_sdk_path('nvidia') version_file_json = '%s/version.json' % chpl_cuda_path @@ -236,11 +236,26 @@ def _validate_cuda_version_impl(): (MIN_REQ_VERSION, MAX_REQ_VERSION, cudaVersion)) return False + # CUDA 12 requires the bundled LLVM or the major LLVM version must be >15 + if is_ver_in_range(cudaVersion, "12", "13"): + llvm = chpl_llvm.get() + if llvm == "system": + llvm_config = chpl_llvm.find_system_llvm_config() + llvm_ver_str = chpl_llvm.get_llvm_config_version(llvm_config).strip() + if is_ver_in_range(llvm_ver_str, "0", "16"): + _reportMissingGpuReq( + "LLVM versions before 16 do not support CUDA 12. " + "Your LLVM (CHPL_LLVM=system) version is {}. " + "You can use CUDA 11, or set CHPL_LLVM=bundled to use " + "CUDA 12.".format(llvm_ver_str), suggestNone=False, + allowExempt=False) + return False + return True def _validate_rocm_version_impl(): - """Check that the installed CUDA version is >= MIN_REQ_VERSION and < + """Check that the installed ROCM version is >= MIN_REQ_VERSION and < MAX_REQ_VERSION""" MIN_REQ_VERSION = "4" MAX_REQ_VERSION = "6" diff --git a/util/cron/test-cray-xc-arkouda.bash b/util/cron/test-cray-xc-arkouda.bash index f9917d737fae..7a102dc20267 100755 --- a/util/cron/test-cray-xc-arkouda.bash +++ b/util/cron/test-cray-xc-arkouda.bash @@ -2,6 +2,7 @@ CWD=$(cd $(dirname $0) ; pwd) +export CHPL_TEST_PERF_CONFIG_NAME='16-node-xc' export CHPL_NIGHTLY_TEST_CONFIG_NAME="cray-xc-arkouda" source $CWD/common.bash diff --git a/util/cron/test-cray-xc-arkouda.release.bash b/util/cron/test-cray-xc-arkouda.release.bash index 5f3d8c6be69d..6555b84edaff 100755 --- a/util/cron/test-cray-xc-arkouda.release.bash +++ b/util/cron/test-cray-xc-arkouda.release.bash @@ -2,6 +2,7 @@ CWD=$(cd $(dirname $0) ; pwd) +export CHPL_TEST_PERF_CONFIG_NAME='16-node-xc' export CHPL_NIGHTLY_TEST_CONFIG_NAME="cray-xc-arkouda.release" source $CWD/common.bash diff --git a/util/cron/test-gpu-ex-cuda-12.bash b/util/cron/test-gpu-ex-cuda-12.bash new file mode 100755 index 000000000000..ec4bb865a37d --- /dev/null +++ b/util/cron/test-gpu-ex-cuda-12.bash @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# GPU native testing on a Cray EX (using none for CHPL_COMM) + +CWD=$(cd $(dirname ${BASH_SOURCE[0]}) ; pwd) +source $CWD/common-native-gpu.bash +source $CWD/common-hpe-cray-ex.bash + +module load cudatoolkit/23.3_12.0 # this is the default on this system + +export CHPL_LLVM=bundled # CUDA 12 is only supported with bundled LLVM +export CHPL_COMM=none +export CHPL_LOCALE_MODEL=gpu +export CHPL_LAUNCHER_PARTITION=allgriz + +export CHPL_GPU=nvidia # amd is also detected automatically + +export CHPL_NIGHTLY_TEST_DIRS="gpu/native" + +export CHPL_NIGHTLY_TEST_CONFIG_NAME="gpu-ex-cuda-12" +$CWD/nightly -cron ${nightly_args}