From 1af3785b80a145e2613618235907fcf6a87e0367 Mon Sep 17 00:00:00 2001 From: brandon-neth <106398756+brandon-neth@users.noreply.github.com> Date: Tue, 7 Nov 2023 12:17:45 -0700 Subject: [PATCH] Drop support for Chapel 1.30 (#2844) * removed 1.30 compatibilyt modules * Removed include statements for the empty compatibility modules. --- Signed-off-by: Brandon Neth * Removed the empty compatibility module files --- Signed-off-by: Brandon Neth * makefile changes for the compatibility module paths * updated CI workflows to use 1.32 and 1.31 for the chapel portability workflow * missed one of the compatibility module paths in the make doc commands --------- Co-authored-by: pierce <48131946+pierce314159@users.noreply.github.com> --- .github/workflows/CI.yml | 12 +- Makefile | 15 +- dep/checkArrow.chpl | 1 - src/BigIntMsg.chpl | 1 - src/CSVMsg.chpl | 1 - src/Codecs.chpl | 1 - src/EfuncMsg.chpl | 1 - src/ExternalIntegration.chpl | 2 - src/GenSymIO.chpl | 2 - src/HDF5Msg.chpl | 2 - src/Message.chpl | 1 - src/MetricsMsg.chpl | 1 - src/MultiTypeRegEntry.chpl | 1 - src/ParquetMsg.chpl | 2 - src/RegistrationMsg.chpl | 1 - src/Registry.chpl | 1 - src/SegStringSort.chpl | 1 - src/SegmentedMsg.chpl | 1 - src/SegmentedString.chpl | 1 - src/ServerConfig.chpl | 1 - src/ServerDaemon.chpl | 1 - src/TransferMsg.chpl | 2 - src/compat/e-130/ArkoudaAggCompat.chpl | 5 - src/compat/e-130/ArkoudaBigIntCompat.chpl | 52 - src/compat/e-130/ArkoudaBitOpsCompat.chpl | 7 - src/compat/e-130/ArkoudaBlockCompat.chpl | 10 - src/compat/e-130/ArkoudaCTypesCompat.chpl | 64 - src/compat/e-130/ArkoudaFileCompat.chpl | 10 - src/compat/e-130/ArkoudaIOCompat.chpl | 72 - src/compat/e-130/ArkoudaListCompat.chpl | 27 - src/compat/e-130/ArkoudaMapCompat.chpl | 7 - src/compat/e-130/ArkoudaMathCompat.chpl | 7 - .../e-130/ArkoudaMemDiagnosticsCompat.chpl | 3 - src/compat/e-130/ArkoudaPOSIXCompat.chpl | 7 - src/compat/e-130/ArkoudaRangeCompat.chpl | 6 - src/compat/e-130/ArkoudaRegexCompat.chpl | 13 - .../e-130/ArkoudaStringBytesCompat.chpl | 99 - src/compat/e-130/ArkoudaSymEntryCompat.chpl | 28 - src/compat/e-130/ArkoudaTimeCompat.chpl | 2256 ----------------- src/compat/e-130/SymArrayDmapCompat.chpl | 95 - src/compat/eq-131/ArkoudaArrayCompat.chpl | 2 - src/compat/eq-131/ArkoudaBitOpsCompat.chpl | 1 - src/compat/eq-131/ArkoudaListCompat.chpl | 1 - .../eq-131/ArkoudaStringBytesCompat.chpl | 1 - src/compat/gt-131/ArkoudaArrayCompat.chpl | 2 - src/compat/gt-131/ArkoudaBitOpsCompat.chpl | 1 - src/compat/gt-131/ArkoudaListCompat.chpl | 1 - .../gt-131/ArkoudaStringBytesCompat.chpl | 1 - tests/server/UnitTestParquetCpp.chpl | 1 - 49 files changed, 11 insertions(+), 2820 deletions(-) delete mode 100644 src/compat/e-130/ArkoudaAggCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaBigIntCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaBitOpsCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaBlockCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaCTypesCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaFileCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaIOCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaListCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaMapCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaMathCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaMemDiagnosticsCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaPOSIXCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaRangeCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaRegexCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaStringBytesCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaSymEntryCompat.chpl delete mode 100644 src/compat/e-130/ArkoudaTimeCompat.chpl delete mode 100644 src/compat/e-130/SymArrayDmapCompat.chpl delete mode 100644 src/compat/eq-131/ArkoudaArrayCompat.chpl delete mode 100644 src/compat/eq-131/ArkoudaBitOpsCompat.chpl delete mode 100644 src/compat/eq-131/ArkoudaListCompat.chpl delete mode 100644 src/compat/eq-131/ArkoudaStringBytesCompat.chpl delete mode 100644 src/compat/gt-131/ArkoudaArrayCompat.chpl delete mode 100644 src/compat/gt-131/ArkoudaBitOpsCompat.chpl delete mode 100644 src/compat/gt-131/ArkoudaListCompat.chpl delete mode 100644 src/compat/gt-131/ArkoudaStringBytesCompat.chpl diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6c5a49f904..7937fe8e8c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,7 +17,7 @@ jobs: mypy: runs-on: ubuntu-latest container: - image: chapel/chapel:1.31.0 + image: chapel/chapel:1.32.0 steps: - uses: actions/checkout@v3 - name: Install dependencies @@ -32,7 +32,7 @@ jobs: docs: runs-on: ubuntu-latest container: - image: chapel/chapel:1.31.0 + image: chapel/chapel:1.32.0 steps: - uses: actions/checkout@v3 - name: Install dependencies @@ -47,7 +47,7 @@ jobs: flake8: runs-on: ubuntu-latest container: - image: chapel/chapel:1.31.0 + image: chapel/chapel:1.32.0 steps: - uses: actions/checkout@v3 - name: Install Dependencies @@ -65,7 +65,7 @@ jobs: matrix: python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.x'] container: - image: chapel/chapel:1.31.0 + image: chapel/chapel:1.32.0 steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -95,7 +95,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - chpl-version: ['1.30.0'] + chpl-version: ['1.31.0'] container: image: chapel/chapel:${{matrix.chpl-version}} steps: @@ -131,7 +131,7 @@ jobs: env: CHPL_RT_NUM_THREADS_PER_LOCALE: ${{matrix.threads}} container: - image: chapel/${{matrix.image}}:1.31.0 + image: chapel/${{matrix.image}}:1.32.0 steps: - uses: actions/checkout@v3 - name: Install dependencies diff --git a/Makefile b/Makefile index dbe883b36d..de1dbe45be 100644 --- a/Makefile +++ b/Makefile @@ -206,15 +206,15 @@ $(ARROW_O): $(ARROW_CPP) $(ARROW_H) make compile-arrow-cpp CHPL_MINOR := $(shell $(CHPL) --version | sed -n "s/chpl version 1\.\([0-9]*\).*/\1/p") -CHPL_VERSION_OK := $(shell test $(CHPL_MINOR) -ge 30 && echo yes) -CHPL_VERSION_WARN := $(shell test $(CHPL_MINOR) -le 30 && echo yes) +CHPL_VERSION_OK := $(shell test $(CHPL_MINOR) -ge 31 && echo yes) +CHPL_VERSION_WARN := $(shell test $(CHPL_MINOR) -le 31 && echo yes) .PHONY: check-chpl check-chpl: ifneq ($(CHPL_VERSION_OK),yes) - $(error Chapel 1.30.0 or newer is required) + $(error Chapel 1.31.0 or newer is required) endif ifeq ($(CHPL_VERSION_WARN),yes) - $(warning Chapel 1.31.0 or newer is recommended) + $(warning Chapel 1.32.0 or newer is recommended) endif ZMQ_CHECK = $(DEP_INSTALL_DIR)/checkZMQ.chpl @@ -328,11 +328,6 @@ ifeq ($(shell expr $(CHPL_MINOR) \= 31),1) ARKOUDA_COMPAT_MODULES += -M $(ARKOUDA_SOURCE_DIR)/compat/eq-131 endif -ifeq ($(shell expr $(CHPL_MINOR) \= 30),1) - CHPL_COMPAT_FLAGS += -sbigintInitThrows=true - ARKOUDA_COMPAT_MODULES += -M $(ARKOUDA_SOURCE_DIR)/compat/e-130 -endif - MODULE_GENERATION_SCRIPT=$(ARKOUDA_SOURCE_DIR)/serverModuleGen.py # This is the main compilation statement section $(ARKOUDA_MAIN_MODULE): check-deps $(ARROW_O) $(ARKOUDA_SOURCES) $(ARKOUDA_MAKEFILES) @@ -421,7 +416,7 @@ doc-server: ${DOC_DIR} $(DOC_SERVER_OUTPUT_DIR)/index.html $(DOC_SERVER_OUTPUT_DIR)/index.html: $(ARKOUDA_SOURCES) $(ARKOUDA_MAKEFILES) | $(DOC_SERVER_OUTPUT_DIR) @echo "Building documentation for: Server" @# Build the documentation to the Chapel output directory - $(CHPLDOC) $(CHPLDOC_FLAGS) $(ARKOUDA_MAIN_SOURCE) $(ARKOUDA_SOURCE_DIR)/compat/e-130/* -o $(DOC_SERVER_OUTPUT_DIR) + $(CHPLDOC) $(CHPLDOC_FLAGS) $(ARKOUDA_MAIN_SOURCE) $(ARKOUDA_SOURCE_DIR)/compat/eq-131/* -o $(DOC_SERVER_OUTPUT_DIR) @# Create the .nojekyll file needed for github pages in the Chapel output directory touch $(DOC_SERVER_OUTPUT_DIR)/.nojekyll @echo "Completed building documentation for: Server" diff --git a/dep/checkArrow.chpl b/dep/checkArrow.chpl index 9424e4f6ca..05237503f9 100644 --- a/dep/checkArrow.chpl +++ b/dep/checkArrow.chpl @@ -1,6 +1,5 @@ use IO; use ArkoudaCTypesCompat; -use ArkoudaStringBytesCompat; require "../src/ArrowFunctions.h"; require "../src/ArrowFunctions.o"; diff --git a/src/BigIntMsg.chpl b/src/BigIntMsg.chpl index c208851303..bb6ee010ad 100644 --- a/src/BigIntMsg.chpl +++ b/src/BigIntMsg.chpl @@ -11,7 +11,6 @@ module BigIntMsg { use BigInteger; use List; - use ArkoudaListCompat; use ArkoudaIOCompat; private config const logLevel = ServerConfig.logLevel; diff --git a/src/CSVMsg.chpl b/src/CSVMsg.chpl index dd5dcf3e66..34eb5a221a 100644 --- a/src/CSVMsg.chpl +++ b/src/CSVMsg.chpl @@ -18,7 +18,6 @@ module CSVMsg { use Set; use ArkoudaFileCompat; - use ArkoudaListCompat; use ArkoudaIOCompat; const CSV_HEADER_OPEN = "**HEADER**"; diff --git a/src/Codecs.chpl b/src/Codecs.chpl index bfc84b8ce8..9878f673d9 100644 --- a/src/Codecs.chpl +++ b/src/Codecs.chpl @@ -5,7 +5,6 @@ module Codecs { use AryUtil; use ArkoudaCTypesCompat; - use ArkoudaStringBytesCompat; use CTypes; proc encodeStr(obj: c_ptr(uint(8)), inBufSize: int, outBufSize: int, toEncoding: string = "UTF-8", fromEncoding: string = "UTF-8"): [] uint(8) throws { diff --git a/src/EfuncMsg.chpl b/src/EfuncMsg.chpl index b40a07b5d6..fa7ba94922 100644 --- a/src/EfuncMsg.chpl +++ b/src/EfuncMsg.chpl @@ -18,7 +18,6 @@ module EfuncMsg use AryUtil; - use ArkoudaBitOpsCompat; use ArkoudaMathCompat; private config const logLevel = ServerConfig.logLevel; diff --git a/src/ExternalIntegration.chpl b/src/ExternalIntegration.chpl index c1cc406bcc..86d5cb7b96 100644 --- a/src/ExternalIntegration.chpl +++ b/src/ExternalIntegration.chpl @@ -7,8 +7,6 @@ module ExternalIntegration { use ServerConfig; use ServerErrors; - use ArkoudaListCompat; - private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; const eiLogger = new Logger(logLevel, logChannel); diff --git a/src/GenSymIO.chpl b/src/GenSymIO.chpl index 3149b3a62d..d4c7992aaa 100644 --- a/src/GenSymIO.chpl +++ b/src/GenSymIO.chpl @@ -20,8 +20,6 @@ module GenSymIO { use CTypes; use ArkoudaMapCompat; - use ArkoudaListCompat; - use ArkoudaStringBytesCompat; use ArkoudaCTypesCompat; use ArkoudaIOCompat; diff --git a/src/HDF5Msg.chpl b/src/HDF5Msg.chpl index d2407875a3..d5076b9ed1 100644 --- a/src/HDF5Msg.chpl +++ b/src/HDF5Msg.chpl @@ -28,8 +28,6 @@ module HDF5Msg { use BigInteger; - use ArkoudaListCompat; - use ArkoudaStringBytesCompat; use ArkoudaCTypesCompat; use ArkoudaIOCompat; diff --git a/src/Message.chpl b/src/Message.chpl index e3ca4d1f31..8195ff10bc 100644 --- a/src/Message.chpl +++ b/src/Message.chpl @@ -9,7 +9,6 @@ module Message { use ArkoudaFileCompat; use Map; - use ArkoudaListCompat; use ArkoudaIOCompat; enum MsgType {NORMAL,WARNING,ERROR} diff --git a/src/MetricsMsg.chpl b/src/MetricsMsg.chpl index 4b3f87c05f..ffce028ce2 100644 --- a/src/MetricsMsg.chpl +++ b/src/MetricsMsg.chpl @@ -13,7 +13,6 @@ module MetricsMsg { use Map; use ArkoudaTimeCompat as Time; - use ArkoudaListCompat; use ArkoudaMapCompat; use ArkoudaIOCompat; diff --git a/src/MultiTypeRegEntry.chpl b/src/MultiTypeRegEntry.chpl index c5a2af6db2..c5f89bed24 100644 --- a/src/MultiTypeRegEntry.chpl +++ b/src/MultiTypeRegEntry.chpl @@ -15,7 +15,6 @@ module MultiTypeRegEntry { use NumPyDType; use ArkoudaIOCompat; - use ArkoudaListCompat; use ArkoudaMapCompat; private config const logLevel = ServerConfig.logLevel; diff --git a/src/ParquetMsg.chpl b/src/ParquetMsg.chpl index aad5bb5a45..c1530e269e 100644 --- a/src/ParquetMsg.chpl +++ b/src/ParquetMsg.chpl @@ -19,8 +19,6 @@ module ParquetMsg { use Map; use ArkoudaCTypesCompat; - use ArkoudaListCompat; - use ArkoudaStringBytesCompat; use ArkoudaIOCompat; enum CompressionType { diff --git a/src/RegistrationMsg.chpl b/src/RegistrationMsg.chpl index dec6df4a3e..492f533fac 100644 --- a/src/RegistrationMsg.chpl +++ b/src/RegistrationMsg.chpl @@ -23,7 +23,6 @@ module RegistrationMsg { use GenSymIO; use ArkoudaIOCompat; - use ArkoudaListCompat; use ArkoudaMapCompat; private config const logLevel = ServerConfig.logLevel; diff --git a/src/Registry.chpl b/src/Registry.chpl index 739a6216fc..431961f93b 100644 --- a/src/Registry.chpl +++ b/src/Registry.chpl @@ -9,7 +9,6 @@ module Registry { use ServerErrors; use Logging; use ArkoudaMapCompat; - use ArkoudaListCompat; private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; diff --git a/src/SegStringSort.chpl b/src/SegStringSort.chpl index 8410433962..e2056bbf71 100644 --- a/src/SegStringSort.chpl +++ b/src/SegStringSort.chpl @@ -11,7 +11,6 @@ module SegStringSort { use ServerConfig; use BlockDist; - use ArkoudaStringBytesCompat; use ArkoudaBlockCompat; private config const SSS_v = false; diff --git a/src/SegmentedMsg.chpl b/src/SegmentedMsg.chpl index f1d46e0d11..d407085e20 100644 --- a/src/SegmentedMsg.chpl +++ b/src/SegmentedMsg.chpl @@ -16,7 +16,6 @@ module SegmentedMsg { use SegmentedArray; use Map; - use ArkoudaStringBytesCompat; use ArkoudaRangeCompat; use ArkoudaCTypesCompat; use ArkoudaIOCompat; diff --git a/src/SegmentedString.chpl b/src/SegmentedString.chpl index 27e1d8bc4d..f528518f86 100644 --- a/src/SegmentedString.chpl +++ b/src/SegmentedString.chpl @@ -22,7 +22,6 @@ module SegmentedString { use FileSystem; use ArkoudaRegexCompat; - use ArkoudaStringBytesCompat; use ArkoudaRangeCompat; private config const logLevel = ServerConfig.logLevel; diff --git a/src/ServerConfig.chpl b/src/ServerConfig.chpl index eba1e33e68..83f6fc1b98 100644 --- a/src/ServerConfig.chpl +++ b/src/ServerConfig.chpl @@ -17,7 +17,6 @@ module ServerConfig use ArkoudaFileCompat; private use ArkoudaCTypesCompat; - use ArkoudaStringBytesCompat; enum Deployment {STANDARD,KUBERNETES} diff --git a/src/ServerDaemon.chpl b/src/ServerDaemon.chpl index d4dd0c62ab..9637665dca 100644 --- a/src/ServerDaemon.chpl +++ b/src/ServerDaemon.chpl @@ -28,7 +28,6 @@ module ServerDaemon { use StatusMsg; use ArkoudaFileCompat; - use ArkoudaListCompat; use ArkoudaIOCompat; enum ServerDaemonType {DEFAULT,INTEGRATION,METRICS,STATUS} diff --git a/src/TransferMsg.chpl b/src/TransferMsg.chpl index 944ee54ba5..a13c63d2c8 100644 --- a/src/TransferMsg.chpl +++ b/src/TransferMsg.chpl @@ -14,8 +14,6 @@ module TransferMsg use ServerErrorStrings; use SegmentedString; - use ArkoudaListCompat; - use ArkoudaStringBytesCompat; use ArkoudaCTypesCompat; proc sendDataFrameSetupInfo(port:string, numColumns: int, elements: string) throws { diff --git a/src/compat/e-130/ArkoudaAggCompat.chpl b/src/compat/e-130/ArkoudaAggCompat.chpl deleted file mode 100644 index 03e1f42a3d..0000000000 --- a/src/compat/e-130/ArkoudaAggCompat.chpl +++ /dev/null @@ -1,5 +0,0 @@ -module ArkoudaAggCompat { - proc yieldTask() { - chpl_task_yield(); - } -} diff --git a/src/compat/e-130/ArkoudaBigIntCompat.chpl b/src/compat/e-130/ArkoudaBigIntCompat.chpl deleted file mode 100644 index 43f7d4ebbf..0000000000 --- a/src/compat/e-130/ArkoudaBigIntCompat.chpl +++ /dev/null @@ -1,52 +0,0 @@ -module ArkoudaBigIntCompat { - public use BigInteger; - - inline operator bigint.:(src: bool, type toType: bigint): bigint throws { - return new bigint(src:int); - } - - proc mod(ref result: bigint, const ref a: bigint, const ref b: bigint) { - result.mod(a, b); - } - - proc mod(ref result: bigint, const ref a: bigint, b: integral) : int { - return result.mod(a, b); - } - - proc powMod(ref result: bigint, - const ref base: bigint, - const ref exp: bigint, - const ref mod: bigint) { - result.powMod(base, exp, mod); - } - - proc powMod(ref result: bigint, - const ref base: bigint, - exp: int, - const ref mod: bigint) { - result.powMod(base, exp, mod); - } - - proc powMod(ref result: bigint, - const ref base: bigint, - exp: uint, - const ref mod: bigint) { - result.powMod(base, exp, mod); - } - - proc rightShift(const ref a: bigint, b: int): bigint { - return a >> b; - } - - proc rightShift(const ref a: bigint, b: uint): bigint { - return a >> b; - } - - proc rightShiftEq(ref a: bigint, b: int) { - a >>= b; - } - - proc rightShiftEq(ref a: bigint, b: uint) { - a >>= b; - } -} diff --git a/src/compat/e-130/ArkoudaBitOpsCompat.chpl b/src/compat/e-130/ArkoudaBitOpsCompat.chpl deleted file mode 100644 index c188ea3b82..0000000000 --- a/src/compat/e-130/ArkoudaBitOpsCompat.chpl +++ /dev/null @@ -1,7 +0,0 @@ -module ArkoudaBitOpsCompat { - use BitOps; - - proc popCount(x: integral) { - return popcount(x); - } -} diff --git a/src/compat/e-130/ArkoudaBlockCompat.chpl b/src/compat/e-130/ArkoudaBlockCompat.chpl deleted file mode 100644 index 89684a998d..0000000000 --- a/src/compat/e-130/ArkoudaBlockCompat.chpl +++ /dev/null @@ -1,10 +0,0 @@ -module ArkoudaBlockCompat { - - use BlockDist; - - type blockDist = Block; - - proc BlockDom.distribution { - return this.dist; - } -} diff --git a/src/compat/e-130/ArkoudaCTypesCompat.chpl b/src/compat/e-130/ArkoudaCTypesCompat.chpl deleted file mode 100644 index 9684d0e1ad..0000000000 --- a/src/compat/e-130/ArkoudaCTypesCompat.chpl +++ /dev/null @@ -1,64 +0,0 @@ -module ArkoudaCTypesCompat { - public use CTypes; - - private proc offset_ARRAY_ELEMENTS { - extern const CHPL_RT_MD_ARRAY_ELEMENTS:chpl_mem_descInt_t; - pragma "fn synchronization free" - extern proc chpl_memhook_md_num(): chpl_mem_descInt_t; - return CHPL_RT_MD_ARRAY_ELEMENTS - chpl_memhook_md_num(); - } - - inline proc allocate(type eltType, size: c_size_t, clear: bool = false, - alignment: c_size_t = 0) : c_ptr(eltType) { - const alloc_size = size * c_sizeof(eltType); - const aligned : bool = (alignment != 0); - var ptr : c_void_ptr = nil; - - // pick runtime allocation function based on requested zeroing + alignment - if (!aligned) { - if (clear) { - // normal calloc - ptr = chpl_here_calloc(alloc_size, 1, offset_ARRAY_ELEMENTS); - } else { - // normal malloc - ptr = chpl_here_alloc(alloc_size, offset_ARRAY_ELEMENTS); - } - } else { - // check alignment, size restriction - // Alignment of 0 is our sentinel value for no specified alignment, - // so no need to check for it. - if boundsChecking { - use Math; - var one:c_size_t = 1; - // Round the alignment up to the nearest power of 2 - var p = log2(alignment); // power of 2 rounded down - // compute alignment rounded up - if (one << p) < alignment then - p += 1; - assert(alignment <= (one << p)); - if alignment != (one << p) then - halt("allocate called with non-power-of-2 alignment ", alignment); - if alignment < c_sizeof(c_void_ptr) then - halt("allocate called with alignment smaller than pointer size"); - } - - // normal aligned alloc, whether we clear after or not - ptr = chpl_here_aligned_alloc(alignment, alloc_size, - offset_ARRAY_ELEMENTS); - - if (clear) { - // there is no aligned calloc; have to aligned_alloc + memset to 0 - c_memset(ptr, 0, alloc_size); - } - } - - return ptr : c_ptr(eltType); - } - - inline proc deallocate(data: c_void_ptr) { - chpl_here_free(data); - } - - type c_string_ptr = c_string; - type c_ptr_void = c_void_ptr; -} diff --git a/src/compat/e-130/ArkoudaFileCompat.chpl b/src/compat/e-130/ArkoudaFileCompat.chpl deleted file mode 100644 index 4100340314..0000000000 --- a/src/compat/e-130/ArkoudaFileCompat.chpl +++ /dev/null @@ -1,10 +0,0 @@ -module ArkoudaFileCompat { - public use IO; - - // We can't just use `readBytes` here because in previous - // releases, `readBytes` had a different meaning, so we - // need to override with a new name - proc fileReader.bytesRead(ref a, b) throws { - this.readBytes(a,b); - } -} diff --git a/src/compat/e-130/ArkoudaIOCompat.chpl b/src/compat/e-130/ArkoudaIOCompat.chpl deleted file mode 100644 index 2f7ddac104..0000000000 --- a/src/compat/e-130/ArkoudaIOCompat.chpl +++ /dev/null @@ -1,72 +0,0 @@ -module ArkoudaIOCompat { - use IO; - - proc formatString(input) throws { - return input:string; - } - - proc formatJson(input): string throws { - return "%jt".format(input); - } - - proc formatJson(input:string, vals...?): string throws { - var toUse = input.replace("%?", "%jt"); - return toUse.format((...vals)); - } - - proc string.doFormat(vals...?): string throws { - var toUse = this.replace('%?', '%t'); - return toUse.format((...vals)); - } - - proc jsonToTupleCompat(json: string, type t) throws { - var f = openMemFile(); - var w = f.writer(); - w.write(json); - w.close(); - var r = f.reader(); - var tup: t; - r.readf("%jt", tup); - r.close(); - return tup; - } - - proc jsonToPdArrayCompat(json: string, size: int) throws { - var f = openMemFile(); - var w = f.writer(); - w.write(json); - w.close(); - var r = f.reader(); - var array: [0..#size] string; - r.readf("%jt", array); - r.close(); - return array; - } - - proc readfCompat(f: file, str: string, ref obj) throws { - var nreader = f.reader(); - nreader.readf("%jt", obj); - } - - proc writefCompat(fmt: ?t, const args ...?k) where isStringType(t) || isBytesType(t) { - var newFmt = fmt.replace('%?', '%t'); - writef(newFmt, (...args)); - } - - proc getByteOrderCompat() throws { - use IO; - var writeVal = 1, readVal = 0; - var tmpf = openMemFile(); - tmpf.writer(kind=iobig).write(writeVal); - tmpf.reader(kind=ionative).read(readVal); - return if writeVal == readVal then "big" else "little"; - } - - proc fileIOReaderCompat(infile) throws { - return infile.reader(kind=ionative); - } - - proc binaryCheckCompat(reader) throws { - return reader.binary(); - } -} diff --git a/src/compat/e-130/ArkoudaListCompat.chpl b/src/compat/e-130/ArkoudaListCompat.chpl deleted file mode 100644 index 89c63c21aa..0000000000 --- a/src/compat/e-130/ArkoudaListCompat.chpl +++ /dev/null @@ -1,27 +0,0 @@ -module ArkoudaListCompat { - use List; - - proc ref list.pushBack(in x: this.eltType): int { - return this.append(x); - } - - proc ref list.pushBack(other: list(this.eltType)) lifetime this < other { - this.append(other); - } - - proc ref list.pushBack(other: [] this.eltType) lifetime this < other { - this.append(other); - } - - proc ref list.pushBack(other: range(this.eltType, ?)) lifetime this < other { - this.append(other); - } - - proc ref list.popBack(): this.eltType { - return this.pop(); - } - - proc ref list.replace(i: int, x: this.eltType): bool { - return this.set(i, x); - } -} diff --git a/src/compat/e-130/ArkoudaMapCompat.chpl b/src/compat/e-130/ArkoudaMapCompat.chpl deleted file mode 100644 index 72afd822ce..0000000000 --- a/src/compat/e-130/ArkoudaMapCompat.chpl +++ /dev/null @@ -1,7 +0,0 @@ -module ArkoudaMapCompat { - public use Map; - - proc map.addOrReplace(in k: keyType, in v: valType) { - this.addOrSet(k, v); - } -} diff --git a/src/compat/e-130/ArkoudaMathCompat.chpl b/src/compat/e-130/ArkoudaMathCompat.chpl deleted file mode 100644 index 9236e67451..0000000000 --- a/src/compat/e-130/ArkoudaMathCompat.chpl +++ /dev/null @@ -1,7 +0,0 @@ -module ArkoudaMathCompat { - inline proc nan param : real(64) do return chpl_NAN; - inline proc inf param : real(64) do return chpl_INFINITY; - - inline proc isNan(x: real(64)): bool do return isnan(x); - inline proc isInf(x: real(64)): bool do return isinf(x); -} diff --git a/src/compat/e-130/ArkoudaMemDiagnosticsCompat.chpl b/src/compat/e-130/ArkoudaMemDiagnosticsCompat.chpl deleted file mode 100644 index 4ab90c86d3..0000000000 --- a/src/compat/e-130/ArkoudaMemDiagnosticsCompat.chpl +++ /dev/null @@ -1,3 +0,0 @@ -module ArkoudaMemDiagnosticsCompat { - public use Memory.Diagnostics; -} diff --git a/src/compat/e-130/ArkoudaPOSIXCompat.chpl b/src/compat/e-130/ArkoudaPOSIXCompat.chpl deleted file mode 100644 index 756b5b0a02..0000000000 --- a/src/compat/e-130/ArkoudaPOSIXCompat.chpl +++ /dev/null @@ -1,7 +0,0 @@ -module ArkoudaPOSIXCompat { - use CTypes; - - inline proc memcpy(dest:c_void_ptr, const src:c_void_ptr, n: c_size_t) { - c_memcpy(dest, src, n); - } -} diff --git a/src/compat/e-130/ArkoudaRangeCompat.chpl b/src/compat/e-130/ArkoudaRangeCompat.chpl deleted file mode 100644 index 20d5df7cb7..0000000000 --- a/src/compat/e-130/ArkoudaRangeCompat.chpl +++ /dev/null @@ -1,6 +0,0 @@ -module ArkoudaRangeCompat { - type stridableRange = range(stridable=true); - proc stridable(a) param { - return a.stridable; - } -} \ No newline at end of file diff --git a/src/compat/e-130/ArkoudaRegexCompat.chpl b/src/compat/e-130/ArkoudaRegexCompat.chpl deleted file mode 100644 index 2101779bce..0000000000 --- a/src/compat/e-130/ArkoudaRegexCompat.chpl +++ /dev/null @@ -1,13 +0,0 @@ -module ArkoudaRegexCompat { - public import Regex.regex; - - // Previous releases of Chapel do not support throwing - // initializers and to work around that, we had to run - // `compile` for each call to match, rather than only - // at regex creation, so here we are updating 1.30 to - // keep the old behavior around so that performance doesn't - // take a hit for previous releases - proc compile(const pattern) throws { - return new regex(pattern); - } -} diff --git a/src/compat/e-130/ArkoudaStringBytesCompat.chpl b/src/compat/e-130/ArkoudaStringBytesCompat.chpl deleted file mode 100644 index 4bbd367e73..0000000000 --- a/src/compat/e-130/ArkoudaStringBytesCompat.chpl +++ /dev/null @@ -1,99 +0,0 @@ -module ArkoudaStringBytesCompat { - - inline proc type - string.createBorrowingBuffer(x: string): string { - return createStringWithBorrowedBuffer(x); - } - - inline proc type - string.createBorrowingBuffer(x: c_string, - length=x.size) - : string throws { - return createStringWithBorrowedBuffer(x, length); - } - - inline proc type - string.createBorrowingBuffer(x: c_ptr(?t), - length: int, - size: int - ): string throws { - return createStringWithBorrowedBuffer(x, length, size); - } - - inline proc type - string.createAdoptingBuffer(x: c_string, length=x.size): string throws { - return createStringWithOwnedBuffer(x, length); - } - - inline proc type - string.createAdoptingBuffer(x: c_ptr(?t), - length: int, - size: int - ): string throws { - return createStringWithOwnedBuffer(x, length, size); - } - - inline proc type - string.createCopyingBuffer(x: c_string, - length=x.size, - policy=decodePolicy.strict - ): string throws { - return createStringWithNewBuffer(x, length, policy); - } - - inline proc type - string.createCopyingBuffer(x: c_ptr(?t), - length: int, - size=length+1, - policy=decodePolicy.strict - ): string throws { - return createStringWithNewBuffer(x, length, size, policy); - } - - - - - inline proc type - bytes.createBorrowingBuffer(x: bytes): bytes { - return createBytesWithBorrowedBuffer(x); - } - - inline proc type - bytes.createBorrowingBuffer(x: c_string, - length=x.size - ): bytes { - return createBytesWithBorrowedBuffer(x, length); - } - - inline proc type - bytes.createBorrowingBuffer(x: c_ptr(?t), - length: int, - size: int - ): bytes { - return createBytesWithBorrowedBuffer(x, length, size); - } - - inline proc type - bytes.createAdoptingBuffer(x: c_string, length=x.size): bytes { - return createBytesWithOwnedBuffer(x, length); - } - - inline proc type - bytes.createAdoptingBuffer(x: c_ptr(?t), length: int, size: int): bytes { - return createBytesWithOwnedBuffer(x, length, size); - } - - inline proc type - bytes.createCopyingBuffer(x: c_string, length=x.size): bytes { - return createBytesWithNewBuffer(x, length); - } - - inline proc type - bytes.createCopyingBuffer(x: c_ptr(?t), - length: int, - size=length+1 - ): bytes { - return createBytesWithNewBuffer(x, length, size); - } - -} diff --git a/src/compat/e-130/ArkoudaSymEntryCompat.chpl b/src/compat/e-130/ArkoudaSymEntryCompat.chpl deleted file mode 100644 index 45f15f4132..0000000000 --- a/src/compat/e-130/ArkoudaSymEntryCompat.chpl +++ /dev/null @@ -1,28 +0,0 @@ -module ArkoudaSymEntryCompat { - use MultiTypeSymEntry; - use Map; - - type SymEntryAny = SymEntry; - type mapAny = map; - - override proc SymEntry.writeThis(f) throws { - use Reflection; - proc writeField(f, param i) throws { - if !isArray(getField(this, i)) { - f.write(getFieldName(this.type, i), " = ", getField(this, i):string); - } else { - f.write(getFieldName(this.type, i), " = ", formatAry(getField(this, i))); - } - } - - super.writeThis(f); - f.write(" {"); - param nFields = numFields(this.type); - for param i in 0..nFields-2 { - writeField(f, i); - f.write(", "); - } - writeField(f, nFields-1); - f.write("}"); - } -} diff --git a/src/compat/e-130/ArkoudaTimeCompat.chpl b/src/compat/e-130/ArkoudaTimeCompat.chpl deleted file mode 100644 index ee781cc83c..0000000000 --- a/src/compat/e-130/ArkoudaTimeCompat.chpl +++ /dev/null @@ -1,2256 +0,0 @@ -/* - * Copyright 2020-2023 Hewlett Packard Enterprise Development LP - * Copyright 2004-2019 Cray Inc. - * Other additional copyright holders may be indicated within. - * - * The entirety of this work is licensed under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - - - -/* Support for routines related to measuring the passing of time. - - This module provides support for querying wall time in the local - timezone and implements a record :record:`~stopwatch` that can measure - the execution time of sections of a program. The stopwatch has the - potential for microsecond resolution and is intended to be useful for - performance testing. - */ - -module ArkoudaTimeCompat { - import HaltWrappers; - private use CTypes; - private use ArkoudaStringBytesCompat; - -// Returns the number of seconds since midnight. Has the potential for -// microsecond resolution if supported by the runtime platform -private extern proc chpl_now_time():real; - - - - - -// This is comparable to a Posix struct timeval -extern type _timevalue; - - - -private extern proc chpl_null_timevalue(): _timevalue; - - - -// The number of seconds/microseconds since Jan 1, 1970 in UTC -private extern proc chpl_now_timevalue(): _timevalue; - - - -// The components of time in the local time zone -private extern proc chpl_timevalue_parts(t: _timevalue, - - out seconds: int(32), - out minutes: int(32), - out hours: int(32), - out mday: int(32), - out month: int(32), - out year: int(32), - out wday: int(32), - out yday: int(32), - out isdst: int(32)); - -/* Specifies the units to be used when certain functions return a time */ -@deprecated(notes="The 'TimeUnits' type is deprecated. Please specify times in seconds in this module.") -enum TimeUnits { microseconds, milliseconds, seconds, minutes, hours } - -/* Specifies the day of the week */ -enum Day { sunday=0, monday, tuesday, wednesday, thursday, friday, saturday } - /* Days in the week, starting with `Monday` = 0 */ - enum dayOfWeek { - Monday = 0, - Tuesday = 1, - Wednesday = 2, - Thursday = 3, - Friday = 4, - Saturday = 5, - Sunday = 6 - } - - - proc DayOfWeek { - compilerError("'DayOfWeek' was renamed. Please use 'dayOfWeek' instead"); - } - - /* Days in the week, starting with `Monday` = 1 */ - enum isoDayOfWeek { - Monday = 1, - Tuesday = 2, - Wednesday = 3, - Thursday = 4, - Friday = 5, - Saturday = 6, - Sunday = 7 - } - - - proc ISODayOfWeek { - compilerError("'ISODayOfWeek was renamed. Please use 'isoDayOfWeek' instead"); - } - - /* The minimum year allowed in `date` objects */ - param MINYEAR = 1; - /* The maximum year allowed in `date` objects */ - param MAXYEAR = 9999; - - private const DAYS_IN_MONTH = (-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); - private const DAYS_BEFORE_MONTH = init_days_before_month(); - - /* The Unix Epoch date and time */ - const unixEpoch = new dateTime(1970, 1, 1); - - private const DI400Y = daysBeforeYear(401); - private const DI100Y = daysBeforeYear(101); - private const DI4Y = daysBeforeYear(5); - - private proc getTimeOfDay() { - extern "struct timeval" record timeval { - var tv_sec: int; - var tv_usec: int; - } - extern proc gettimeofday(ref tv: timeval, tz): int; - - var tv: timeval; - var ret = gettimeofday(tv, c_nil); - assert(ret == 0); - return (tv.tv_sec, tv.tv_usec); - } - - private proc tm_zoneType type { - use ChplConfig; - if CHPL_TARGET_PLATFORM == "darwin" then - return c_ptr(c_char); // char * - else - return c_string; // const char * - } - - proc createFromTimestampCompat(d) { - return date.createFromTimestamp(d); - } - - /* Get the `time` since Unix Epoch in seconds - */ - proc timeSinceEpoch(): timedelta { - var (seconds,microseconds):(real,real) = getTimeOfDay(); - microseconds = microseconds/1000000.0; - return new timedelta(seconds + microseconds); - } - - - extern "struct tm" record tm { - var tm_sec: c_int; // seconds [0,61] - var tm_min: c_int; // minutes [0,59] - var tm_hour: c_int; // hour [0,23] - var tm_mday: c_int; // day of month [1,31] - var tm_mon: c_int; // month of year [0,11] - var tm_year: c_int; // years since 1900 - var tm_wday: c_int; // day of week [0,6] (Sunday = 0) - var tm_yday: c_int; // day of year [0,365] - var tm_isdst: c_int; // daylight savings flag - var tm_gmtoff: c_long; // Seconds east of UTC - var tm_zone: tm_zoneType; // Timezone abbreviation - } - - private proc assertInRange(val, low, high) { - assert(val >= low && val <= high); - } - - private proc getLocalTime(t: 2*int) { - extern type time_t; - - extern proc localtime_r(const ref t: time_t, ref resultp: tm): void; - - const t1: time_t = __primitive("cast", time_t, t(0)); - var breakDownTime: tm; - - localtime_r(t1, breakDownTime); - return breakDownTime; - } - - private proc init_days_before_month() { - var DBM: 13*int; - for i in 2..12 { - DBM[i] = DBM[i-1] + DAYS_IN_MONTH[i-1]; - } - return DBM; - } - - private proc daysBeforeYear(year: int) { - const y = year - 1; - return y*365 + y/4 - y/100 + y/400; - } - - // assumes callee has checked for valid month range - private proc daysBeforeMonth(year: int, month: int) { - assertInRange(month, 1, 12); - return DAYS_BEFORE_MONTH(month) + if (month > 2 && isLeapYear(year)) then 1 else 0; - } - - // assumes callee has checked for valid month/day ranges - private proc ymdToOrd(year: int, month: int, day: int) { - assertInRange(month, 1, 12); - const dim = try! daysInMonth(year, month); - assertInRange(day, 1, dim); - return daysBeforeYear(year) + daysBeforeMonth(year, month) + day; - } - - private proc ordToYmd(in n: int) { - n -= 1; - const n400 = n / DI400Y; - n = n % DI400Y; - var year = n400*400 + 1; - - const n100 = n / DI100Y; - n = n % DI100Y; - - const n4 = n / DI4Y; - n = n % DI4Y; - - const n1 = n / 365; - n = n % 365; - - year += n100*100 + n4*4 + n1; - - if n1 == 4 || n100 == 4 { - assert(n == 0); - return (year-1, 12, 31); - } - - const leapyear = n1 == 3 && (n4 != 24 || n100 == 3); - assert(leapyear == isLeapYear(year)); - - var month = (n+50) >> 5; - var preceding = daysBeforeMonth(year, month); - if preceding > n { - month -= 1; - if month == 0 { - month = 12; - year -= 1; - } - const dim = try! daysInMonth(year, month); - preceding -= dim; - } - n -= preceding; - const dim = try! daysInMonth(year, month); - assertInRange(n+1, 1, dim); - return (year, month, n+1); - } - - /* Return true if `year` is a leap year */ - proc isLeapYear(year: int) { - return (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)); - } - - /* Return the number of days in month `month` during the year `year`. - The number for a month can change from year to year due to leap years. - - :throws IllegalArgumentError: Thrown if `month` is out of range. -*/ - proc daysInMonth(year: int, month: int) throws { - if month < 1 || month > 12 then - throw new owned IllegalArgumentError("month must be between 1 and 12"); - if month == 2 && isLeapYear(year) then - return 29; - else - return DAYS_IN_MONTH(month); - } - -/* A record representing a date */ - record date { - - var chpl_year, chpl_month, chpl_day: int; - - /* The year represented by this `date` value */ - proc year { - return chpl_year; - } - - /* The month represented by this `date` value */ - proc month { - return chpl_month; - } - - /* The day represented by this `date` value */ - proc day { - return chpl_day; - } - - /* The minimum representable `date` */ - proc type min { - return new date(MINYEAR, 1, 1); - } - - /* The maximum representable `date` */ - proc type max { - return new date(MAXYEAR, 12, 31); - } - - /* The minimum non-zero difference between two dates */ - proc type resolution { - return new timedelta(days=1); - } - - proc isoWeekDate() { - return this.isoCalendar(); - } - } - - /* initializers/factories for date values */ - - - proc date.init() { - } - - /* Initialize a new `date` value from a `year`, `month`, and `day`. All - three arguments are required and must be in valid ranges. The - valid ranges are: - - 1 <= `year` <= 9999 - - 1 <= `month` <= 12 - - 1 <= `day` <= the number of days in the given month and year - */ - proc date.init(year: int, month: int, day: int) { - if year < MINYEAR-1 || year > MAXYEAR+1 then - HaltWrappers.initHalt("year is out of the valid range"); - if month < 1 || month > 12 then - HaltWrappers.initHalt("month is out of the valid range"); - const dim = try! daysInMonth(year, month); - if day < 1 || day > dim then - HaltWrappers.initHalt("day is out of the valid range"); - - this.chpl_year = year; - this.chpl_month = month; - this.chpl_day = day; - } - - /* A `date` object representing the current day */ - proc type date.today() { - const timeSinceEpoch = getTimeOfDay(); - const td = new timedelta(seconds=timeSinceEpoch(0), - microseconds=timeSinceEpoch(1)); - - return unixEpoch.getdate() + td; - } - - /* The date that is `timestamp` seconds from the epoch */ - proc type date.createFromTimestamp(timestamp) { - const sec = timestamp: int; - const us = ((timestamp-sec) * 1000000 + 0.5): int; - const td = new timedelta(seconds=sec, microseconds=us); - return unixEpoch.getdate() + td; - } - - /* The `date` that is `ord` days from 1-1-0001 */ - proc type date.fromOrdinal(ord) { - if ord < 0 || ord > 1+date.max.toOrdinal() then - halt("ordinal (", ord, ") out of range"); - const (y,m,d) = ordToYmd(ord); - return new date(y,m,d); - } - - /* Methods on date values */ - - /* Replace the `year`, `month` and/or `day` in a date to create a - new `date` */ - proc date.replace(year=0, month=0, day=0) { - const newYear = if year > 0 then year else this.year; - const newMonth = if month > 0 then month else this.month; - const newDay = if day > 0 then day else this.day; - return new date(newYear, newMonth, newDay); - } - - /* Return a filled record matching the C `struct tm` type for the given date */ - @unstable("'date.timetuple' is unstable") - proc date.timetuple() { - var timeStruct: tm; - - timeStruct.tm_hour = 0; - timeStruct.tm_min = 0; - timeStruct.tm_sec = 0; - - timeStruct.tm_mday = day: int(32); - timeStruct.tm_mon = month: int(32); - timeStruct.tm_year = year: int(32); - timeStruct.tm_wday = weekday(): int(32); - timeStruct.tm_yday = (toOrdinal() - (new date(year, 1, 1)).toOrdinal() + 1): int(32); - timeStruct.tm_isdst = (-1): int(32); - return timeStruct; - } - - /* Return the number of days since 1-1-0001 this `date` represents */ - proc date.toOrdinal() { - return ymdToOrd(year, month, day); - } - - /* Return the day of the week as a `dayOfWeek`. - `Monday` == 0, `Sunday` == 6 - */ - proc date.weekday() { - // January 1 0001 is a Monday - return try! ((toOrdinal() + 6) % 7): dayOfWeek; - } - - /* Return the day of the week as an `isoDayOfWeek`. - `Monday` == 1, `Sunday` == 7 */ - proc date.isoWeekday() { - return try! (weekday(): int + 1): isoDayOfWeek; - } - - /* Return the ISO date as a tuple containing the ISO year, ISO week number, - and ISO day of the week - */ - proc date.isoCalendar() { - proc findThursday(d: date) { - var wd = d.weekday(); - return d + new timedelta(days = (dayOfWeek.Thursday:int - wd:int)); - } - - proc findyear(d: date) { - return findThursday(d).year; - } - - proc findFirstDayOfYear(year) { - var thu = findThursday((new date(year, 1, 1))); - if thu.year < year { - return thu + new timedelta(days=4); - } else { // thu.year == year - return thu + new timedelta(days=-3); - } - } - - const y = findyear(this); - const firstDay = findFirstDayOfYear(y); - const delta = this - firstDay; - - return (y, 1+delta.days/7, isoWeekday(): int); - } - - /* Return the date as a `string` in ISO 8601 format: "YYYY-MM-DD" */ - proc date.isoFormat() { - var yearstr = year: string; - var monthstr = month: string; - var daystr = day: string; - - if year < 10 then - yearstr = "000" + yearstr; - else if year < 100 then - yearstr = "00" + yearstr; - else if year < 1000 then - yearstr = "0" + yearstr; - - if month < 10 then - monthstr = "0" + monthstr; - if day < 10 then - daystr = "0" + daystr; - - return yearstr + "-" + monthstr + "-" + daystr; - } - - /* Return a `string` representing the date */ - @unstable("'date.ctime' is unstable") - proc date.ctime() { - const month = strftime("%b"); - const wday = strftime("%a"); - - const extraSpace = if day < 10 then " " else ""; - return wday + " " + month + - " " + extraSpace + day:string + " 00:00:00 " + year: string; - } - - /* Return a formatted `string` matching the `format` argument and the date */ - @unstable("'date.strftime' is unstable") - proc date.strftime(fmt: string) { - extern proc strftime(s: c_void_ptr, size: c_size_t, format: c_string, ref timeStruct: tm); - const bufLen: c_size_t = 100; - var buf: [1..bufLen] c_char; - var timeStruct: tm; - - timeStruct.tm_sec = 0; - timeStruct.tm_min = 0; - timeStruct.tm_hour = 0; - timeStruct.tm_isdst = 0; - timeStruct.tm_gmtoff = 0; - timeStruct.tm_zone = nil; - - timeStruct.tm_year = (year-1900): int(32); // 1900 based - timeStruct.tm_mon = (month-1): int(32); // 0 based - timeStruct.tm_mday = day: int(32); - timeStruct.tm_wday = (weekday(): int(32) + 1) % 7; // shift Sunday to 0 - timeStruct.tm_yday = (this - new date(year, 1, 1)).days: int(32); - - strftime(c_ptrTo(buf), bufLen, fmt.c_str(), timeStruct); - var str: string; - try! { - str = string.createCopyingBuffer(c_ptrTo(buf):c_string); - } - return str; - } - - private use IO; - - // This method exists to work around a bug in chpldoc where the - // 'private use' above this method somehow breaks documentation for the - // method that follows (formerly 'writeThis') - - proc date._chpldoc_workaround() { } - - /* Writes this `date` in ISO 8601 format: YYYY-MM-DD */ - proc date.writeThis(f) throws { - f.write(isoFormat()); - } - - // Exists to support some common functionality for `dateTime.readThis` - - proc date._readCore(f) throws { - const dash = "-"; - - chpl_year = f.read(int); - f._readLiteral(dash); - chpl_month = f.read(int); - f._readLiteral(dash); - chpl_day = f.read(int); - } - - /* Reads this `date` from ISO 8601 format: YYYY-MM-DD */ - proc date.readThis(f) throws { - const binary = f.binary(), - arrayStyle = f.styleElement(QIO_STYLE_ELEMENT_ARRAY), - isjson = arrayStyle == QIO_ARRAY_FORMAT_JSON && !binary; - - if isjson then - f._readLiteral('"'); - - this._readCore(f); - - if isjson then - f._readLiteral('"'); - } - - // - // TODO: need to get this to work with the Json formatter - // - - proc date.init(f: fileReader) { - this.init(); - readThis(f); - } - - /* Operators on date values */ - - operator date.+(d: date, t: timedelta): date { - return date.fromOrdinal(d.toOrdinal() + t.days); - } - - - operator date.+(t: timedelta, d: date): date { - return d + t; - } - - - operator date.-(d: date, t: timedelta): date { - return date.fromOrdinal(d.toOrdinal() - t.days); - } - - - operator date.-(d1: date, d2: date): timedelta { - return new timedelta(days=d1.toOrdinal() - d2.toOrdinal()); - } - - - operator date.<(d1: date, d2: date) { - return d1.toOrdinal() < d2.toOrdinal(); - } - - - operator date.<=(d1: date, d2: date) { - return d1.toOrdinal() <= d2.toOrdinal(); - } - - - operator date.>(d1: date, d2: date) { - return d1.toOrdinal() > d2.toOrdinal(); - } - - - operator date.>=(d1: date, d2: date) { - return d1.toOrdinal() >= d2.toOrdinal(); - } - - - /* A record representing a time */ - record time { - - var chpl_hour, chpl_minute, chpl_second, chpl_microsecond: int; - - var chpl_tz: shared Timezone?; - - /* The hour represented by this `time` value */ - proc hour { - return chpl_hour; - } - - /* The minute represented by this `time` value */ - proc minute { - return chpl_minute; - } - - /* The second represented by this `time` value */ - proc second { - return chpl_second; - } - - /* The microsecond represented by this `time` value */ - proc microsecond { - return chpl_microsecond; - } - - /* The timezone represented by this `time` value */ - proc timezone { - return chpl_tz; - } - - - @deprecated(notes="'tzinfo' is deprecated, please use 'timezone' instead") - proc tzinfo { - return timezone; - } - - /* The minimum representable `time` */ - proc type min { - return new time(); - } - - /* The maximum representable `time` */ - proc type max { - return new time(23, 59, 59, 999999); - } - - /* The minimum non-zero difference between two times */ - proc type resolution { - return new timedelta(microseconds=1); - } - } - - /* initializers/factories for time values */ - - /* Initialize a new `time` value from the given `hour`, `minute`, `second`, - `microsecond`, and `timezone`. All arguments are optional - */ - @unstable("tz is unstable; its type may change in the future") - proc time.init(hour:int=0, minute:int=0, second:int=0, microsecond:int=0, - in tz: shared Timezone?) { - if hour < 0 || hour >= 24 then - HaltWrappers.initHalt("hour out of range"); - if minute < 0 || minute >= 60 then - HaltWrappers.initHalt("minute out of range"); - if second < 0 || second >= 60 then - HaltWrappers.initHalt("second out of range"); - if microsecond < 0 || microsecond >= 1000000 then - HaltWrappers.initHalt("microsecond out of range"); - this.chpl_hour = hour; - this.chpl_minute = minute; - this.chpl_second = second; - this.chpl_microsecond = microsecond; - this.chpl_tz = tz; - } - - /* Initialize a new `time` value from the given `hour`, `minute`, `second`, - `microsecond`. All arguments are optional - */ - proc time.init(hour:int=0, minute:int=0, second:int=0, microsecond:int=0) { - if hour < 0 || hour >= 24 then - HaltWrappers.initHalt("hour out of range"); - if minute < 0 || minute >= 60 then - HaltWrappers.initHalt("minute out of range"); - if second < 0 || second >= 60 then - HaltWrappers.initHalt("second out of range"); - if microsecond < 0 || microsecond >= 1000000 then - HaltWrappers.initHalt("microsecond out of range"); - this.chpl_hour = hour; - this.chpl_minute = minute; - this.chpl_second = second; - this.chpl_microsecond = microsecond; - this.chpl_tz = nil; - } - - /* Initialize a new `time` value from the given `hour`, `minute`, `second`, - `microsecond`, and `timezone`. All arguments are optional - */ - - - proc time.deinit() { - } - - /* Methods on time values */ - - /* Replace the `hour`, `minute`, `second`, `microsecond` in a - `time` to create a new `time`. All arguments are optional. - */ - proc time.replace(hour=-1, minute=-1, second=-1, microsecond=-1) { - const newhour = if hour != -1 then hour else this.hour; - const newminute = if minute != -1 then minute else this.minute; - const newsecond = if second != -1 then second else this.second; - const newmicrosecond = if microsecond != -1 then microsecond else this.microsecond; - - return new time(newhour, newminute, newsecond, newmicrosecond); - } - - /* Replace the `hour`, `minute`, `second`, `microsecond` and `tz` in a - `time` to create a new `time`. All arguments are optional. - */ - @unstable("tz is unstable; its type may change in the future") - proc time.replace(hour=-1, minute=-1, second=-1, microsecond=-1, - in tz) { - const newhour = if hour != -1 then hour else this.hour; - const newminute = if minute != -1 then minute else this.minute; - const newsecond = if second != -1 then second else this.second; - const newmicrosecond = if microsecond != -1 then microsecond else this.microsecond; - - return new time(newhour, newminute, newsecond, newmicrosecond, tz); - } - - /* Return a `string` representing the `time` in ISO format */ - proc time.isoFormat() { - proc makeNDigits(n, d) { - var ret = d: string; - while ret.size < n { - ret = "0" + ret; - } - return ret; - } - - var ret = makeNDigits(2, hour) + ":" + - makeNDigits(2, minute) + ":" + - makeNDigits(2, second); - - if microsecond != 0 { - ret = ret + "." + makeNDigits(6, microsecond); - } - var offset = utcOffset(); - if timezone.borrow() != nil { - var sign: string; - if offset.days < 0 { - offset = -offset; - sign = "-"; - } else { - sign = "+"; - } - ret = ret + sign + makeNDigits(2, offset.seconds/(60*60)) + ":" + - makeNDigits(2, offset.seconds % (60*60) / 60); - } - return ret; - } - - /* Return the offset from UTC */ - proc time.utcOffset() { - if timezone.borrow() == nil { - return new timedelta(); - } else { - return timezone!.utcOffset(dateTime.now()); - } - } - - /* Return the daylight saving time offset */ - proc time.dst() { - if timezone.borrow() == nil { - return new timedelta(); - } else { - return timezone!.dst(dateTime.now()); - } - } - - /* Return the name of the timezone for this `time` value */ - proc time.tzname() { - if timezone.borrow() == nil then - return ""; - else - return timezone!.tzname(new dateTime(1,1,1)); - } - - /* Return a `string` matching the `format` argument for this `time` */ - @unstable("'time.strftime' is unstable") - proc time.strftime(fmt: string) { - extern proc strftime(s: c_void_ptr, size: c_size_t, format: c_string, ref timeStruct: tm); - const bufLen: c_size_t = 100; - var buf: [1..bufLen] c_char; - var timeStruct: tm; - - timeStruct.tm_sec = second: int(32); - timeStruct.tm_min = minute: int(32); - timeStruct.tm_hour = hour: int(32); - timeStruct.tm_year = 0; - timeStruct.tm_mday = 1; - timeStruct.tm_mon = 1; - - timeStruct.tm_wday = ((new date(1900, 1, 1)).weekday():int(32) + 1) % 7; - timeStruct.tm_yday = 0; - - if timezone.borrow() != nil { - timeStruct.tm_gmtoff = abs(utcOffset()).seconds: c_long; - timeStruct.tm_zone = __primitive("cast", tm_zoneType, tzname().c_str()); - timeStruct.tm_isdst = dst().seconds: int(32); - } else { - timeStruct.tm_gmtoff = 0; - timeStruct.tm_zone = __primitive("cast", tm_zoneType, "".c_str()); - timeStruct.tm_isdst = -1; - } - - strftime(c_ptrTo(buf), bufLen, fmt.c_str(), timeStruct); - var str: string; - try! { - str = string.createCopyingBuffer(c_ptrTo(buf):c_string); - } - - return str; - } - - /* Writes this `time` in ISO format: hh:mm:ss.sss */ - proc time.writeThis(f) throws { - f.write(isoFormat()); - } - - // Exists to support some common functionality for `dateTime.readThis` - - proc time._readCore(f) throws { - const colon = ":"; - - chpl_hour = f.read(int); - f._readLiteral(colon); - chpl_minute = f.read(int); - f._readLiteral(colon); - chpl_second = f.read(int); - f._readLiteral("."); - chpl_microsecond = f.read(int); - } - - /* Reads this `time` from ISO format: hh:mm:ss.sss */ - proc time.readThis(f) throws { - const binary = f.binary(), - arrayStyle = f.styleElement(QIO_STYLE_ELEMENT_ARRAY), - isjson = arrayStyle == QIO_ARRAY_FORMAT_JSON && !binary; - - if isjson then - f._readLiteral('"'); - - this._readCore(f); - - if isjson then - f._readLiteral('"'); - } - - // - // TODO: need to get this to work with the Json formatter - // - - proc time.init(f: fileReader) { - this.init(); - readThis(f); - } - - - /* Operators on time values */ - - - operator time.==(t1: time, t2: time): bool { - var dt1 = dateTime.combine(d=new date(2000, 1, 1), t=t1); - var dt2 = dateTime.combine(d=new date(2000, 1, 1), t=t2); - return dt1 == dt2; - } - - - operator time.!=(t1: time, t2: time) { - return !(t1 == t2); - } - - - operator time.<(t1: time, t2: time): bool { - if (t1.timezone.borrow() != nil && t2.timezone.borrow() == nil) || - (t1.timezone.borrow() == nil && t2.timezone.borrow() != nil) { - halt("both dateTimes must both be either naive or aware"); - } else if t1.timezone == t2.timezone { - const sec1 = t1.hour*3600 + t1.minute*60 + t1.second; - const usec1 = t1.microsecond; - const sec2 = t2.hour*3600 + t2.minute*60 + t2.second; - const usec2 = t2.microsecond; - if sec1 < sec2 then - return true; - else if sec1 == sec2 then - return usec1 < usec2; - else - return false; - } else { - // As far as I can tell, python's dateTime.time() comparisons don't - // pay attention to the timezones. - // >>> central = pytz.timezone("US/Central") - // >>> pacific = pytz.timezone("US/Pacific") - // >>> dateTime.time(12,3,4,5,tz=central) > - // dateTime.time(12,3,4,5,tz=pacific) - // False - // >>> dateTime.time(12,3,4,6,tz=central) > - // dateTime.time(12,3,4,5,tz=pacific) - // True - // - // This compares the time on a specific date, and factors in the - // time zones. - const dt1 = dateTime.combine(new date(1900, 1, 1), t1); - const dt2 = dateTime.combine(new date(1900, 1, 1), t2); - return dt1 < dt2; - //return (t1.replace(tz=nil) - t1.utcOffset()) < - // (t2.replace(tz=nil) - t2.utcOffset()); - } - } - - - operator time.<=(t1: time, t2: time): bool { - if (t1.timezone.borrow() != nil && t2.timezone.borrow() == nil) || - (t1.timezone.borrow() == nil && t2.timezone.borrow() != nil) { - halt("both dateTimes must both be either naive or aware"); - } else if t1.timezone == t2.timezone { - const sec1 = t1.hour*3600 + t1.minute*60 + t1.second; - const usec1 = t1.microsecond; - const sec2 = t2.hour*3600 + t2.minute*60 + t2.second; - const usec2 = t2.microsecond; - if sec1 < sec2 then - return true; - else if sec1 == sec2 then - return usec1 <= usec2; - else - return false; - } else { - const dt1 = dateTime.combine(new date(1900, 1, 1), t1); - const dt2 = dateTime.combine(new date(1900, 1, 1), t2); - return dt1 <= dt2; - } - } - - - operator time.>(t1: time, t2: time): bool { - if (t1.timezone.borrow() != nil && t2.timezone.borrow() == nil) || - (t1.timezone.borrow() == nil && t2.timezone.borrow() != nil) { - halt("both dateTimes must both be either naive or aware"); - } else if t1.timezone == t2.timezone { - const sec1 = t1.hour*3600 + t1.minute*60 + t1.second; - const usec1 = t1.microsecond; - const sec2 = t2.hour*3600 + t2.minute*60 + t2.second; - const usec2 = t2.microsecond; - if sec1 > sec2 then - return true; - else if sec1 == sec2 then - return usec1 > usec2; - else - return false; - } else { - const dt1 = dateTime.combine(new date(1900, 1, 1), t1); - const dt2 = dateTime.combine(new date(1900, 1, 1), t2); - return dt1 > dt2; - } - } - - - operator time.>=(t1: time, t2: time): bool { - if (t1.timezone.borrow() != nil && t2.timezone.borrow() == nil) || - (t1.timezone.borrow() == nil && t2.timezone.borrow() != nil) { - halt("both dateTimes must both be either naive or aware"); - } else if t1.timezone == t2.timezone { - const sec1 = t1.hour*3600 + t1.minute*60 + t1.second; - const usec1 = t1.microsecond; - const sec2 = t2.hour*3600 + t2.minute*60 + t2.second; - const usec2 = t2.microsecond; - if sec1 > sec2 then - return true; - else if sec1 == sec2 then - return usec1 >= usec2; - else - return false; - } else { - const dt1 = dateTime.combine(new date(1900, 1, 1), t1); - const dt2 = dateTime.combine(new date(1900, 1, 1), t2); - return dt1 >= dt2; - } - } - - /* A record representing a combined `date` and `time` */ - record dateTime { - - var chpl_date: date; - - var chpl_time: time; - - /* The minimum representable `date` and `time` */ - proc type min { - return this.combine(date.min, time.min); - } - - /* The maximum representable `date` and `time` */ - proc type max { - return this.combine(date.max, time.max); - } - - /* The minimum non-zero difference between two dateTimes */ - proc type resolution { - return new timedelta(microseconds=1); - } - - /* The year represented by this `dateTime` value */ - proc year { - return chpl_date.year; - } - - /* The month represented by this `dateTime` value */ - proc month { - return chpl_date.month; - } - - /* The day represented by this `dateTime` value */ - proc day { - return chpl_date.day; - } - - /* The hour represented by this `dateTime` value */ - proc hour { - return chpl_time.hour; - } - - /* The minute represented by this `dateTime` value */ - proc minute { - return chpl_time.minute; - } - - /* The second represented by this `dateTime` value */ - proc second { - return chpl_time.second; - } - - /* The microsecond represented by this `dateTime` value */ - proc microsecond { - return chpl_time.microsecond; - } - - /* The timezone represented by this `dateTime` value */ - proc timezone { - return chpl_time.timezone; - } - - - @deprecated(notes="'tzinfo' is deprecated, please use 'timezone' instead") - proc tzinfo { - return timezone; - } - } - - /* initializers/factories for dateTime values */ - - - proc dateTime.init() { - } - - /* Initialize a new `dateTime` value from the given `year`, `month`, `day`, - `hour`, `minute`, `second`, `microsecond` and timezone. The `year`, - `month`, and `day` arguments are required, the rest are optional. - */ - @unstable("tz is unstable; its type may change in the future") - proc dateTime.init(year:int, month:int, day:int, - hour:int=0, minute:int=0, second:int=0, microsecond:int=0, - in tz) { - chpl_date = new date(year, month, day); - chpl_time = new time(hour, minute, second, microsecond, tz); - } - - /* Initialize a new `dateTime` value from the given `year`, `month`, `day`, - `hour`, `minute`, `second`, `microsecond` and timezone. The `year`, - `month`, and `day` arguments are required, the rest are optional. - */ - proc dateTime.init(year:int, month:int, day:int, - hour:int=0, minute:int=0, second:int=0, microsecond:int=0) { - chpl_date = new date(year, month, day); - chpl_time = new time(hour, minute, second, microsecond); - } - - /* Initialize a new `dateTime` value from the given `date` and `time` */ - proc dateTime.init(d: date, t: time) { - chpl_date = d; - chpl_time = t; - } - - /* Return a `dateTime` value representing the current time and date */ - proc type dateTime.now() { - const timeSinceEpoch = getTimeOfDay(); - const lt = getLocalTime(timeSinceEpoch); - return new dateTime(year=lt.tm_year+1900, month=lt.tm_mon+1, - day=lt.tm_mday, hour=lt.tm_hour, - minute=lt.tm_min, second=lt.tm_sec, - microsecond=timeSinceEpoch(1)); - } - - /* Return a `dateTime` value representing the current time and date */ - proc type dateTime.now(in tz: shared Timezone?) { - if tz.borrow() == nil { - const timeSinceEpoch = getTimeOfDay(); - const lt = getLocalTime(timeSinceEpoch); - return new dateTime(year=lt.tm_year+1900, month=lt.tm_mon+1, - day=lt.tm_mday, hour=lt.tm_hour, - minute=lt.tm_min, second=lt.tm_sec, - microsecond=timeSinceEpoch(1)); - } else { - const timeSinceEpoch = getTimeOfDay(); - const td = new timedelta(seconds=timeSinceEpoch(0), - microseconds=timeSinceEpoch(1)); - const utcNow = unixEpoch + td; - - return (utcNow + tz!.utcOffset(utcNow)).replace(tz=tz); - } - } - - /* Return a `dateTime` value representing the current time and date in UTC */ - proc type dateTime.utcNow() { - const timeSinceEpoch = getTimeOfDay(); - const td = new timedelta(seconds=timeSinceEpoch(0), - microseconds=timeSinceEpoch(1)); - return unixEpoch + td; - } - - /* The `dateTime` that is `timestamp` seconds from the epoch */ - proc type dateTime.createFromTimestamp(timestamp: real) { - return dateTime.createFromTimestamp(timestamp, nil); - } - - /* The `dateTime` that is `timestamp` seconds from the epoch */ - @unstable("tz is unstable; its type may change in the future") - proc type dateTime.createFromTimestamp(timestamp: real, - in tz: shared Timezone?) { - if tz.borrow() == nil { - var t = (timestamp: int, ((timestamp - timestamp: int)*1000000): int); - const lt = getLocalTime(t); - return new dateTime(year=lt.tm_year+1900, month=lt.tm_mon+1, - day=lt.tm_mday, hour=lt.tm_hour, - minute=lt.tm_min, second=lt.tm_sec, - microsecond=t(1)); - } else { - var dt = dateTime.utcFromTimestamp(timestamp); - return (dt + tz!.utcOffset(dt)).replace(tz=tz); - } - } - - /* The `dateTime` that is `timestamp` seconds from the epoch in UTC */ - proc type dateTime.utcFromTimestamp(timestamp) { - return unixEpoch + new timedelta(seconds=timestamp: int, microseconds=((timestamp-timestamp: int)*1000000): int); - } - - /* The `dateTime` that is `ordinal` days from 1-1-0001 */ - proc type dateTime.fromOrdinal(ordinal) { - return dateTime.combine(date.fromOrdinal(ordinal), new time()); - } - - /* Form a `dateTime` value from a given `date` and `time` */ - proc type dateTime.combine(d: date, t: time) { - return new dateTime(d.year, d.month, d.day, - t.hour, t.minute, t.second, t.microsecond, t.timezone); - } - - /* Methods on dateTime values */ - - /* Get the `date` portion of the `dateTime` value */ - proc dateTime.getdate() { - return chpl_date; - } - - /* Get the `time` portion of the `dateTime` value, with `tz` = nil */ - proc dateTime.gettime() { - if chpl_time.timezone.borrow() == nil then - return chpl_time; - else - return new time(hour=hour, minute=minute, - second=second, microsecond=microsecond); - } - - /* Get the `time` portion of the `dateTime` value including the - `tz` field - */ - proc dateTime.timetz() { - return chpl_time; - } - - /* Replace the `year`, `month`, `day`, `hour`, `minute`, `second`, - `microsecond`, or `tz` to form a new `dateTime` object. All - arguments are optional. - */ - proc dateTime.replace(year=-1, month=-1, day=-1, - hour=-1, minute=-1, second=-1, microsecond=-1, - in tz=this.timezone) { - return dateTime.combine( - new date(if year == -1 then this.year else year, - if month == -1 then this.month else month, - if day == -1 then this.day else day), - new time(if hour == -1 then this.hour else hour, - if minute == -1 then this.minute else minute, - if second == -1 then this.second else second, - if microsecond == -1 then this.microsecond else microsecond, - tz)); - } - - /* Return the date and time converted into the timezone in the argument */ - @unstable("tz is unstable; its type may change in the future") - proc dateTime.astimezone(in tz: shared Timezone) { - if timezone == tz { - return this; - } - const utc = (this - this.utcOffset()).replace(tz=tz); - return tz.borrow().fromUtc(utc); - } - - /* Return the offset from UTC */ - proc dateTime.utcOffset() { - if timezone.borrow() == nil { - halt("utcOffset called on naive dateTime"); - } else { - return timezone!.utcOffset(this); - } - } - /* Return the daylight saving time offset */ - proc dateTime.dst() { - if timezone.borrow() == nil then - halt("dst() called with nil timezone"); - return timezone!.dst(this); - } - - /* Return the name of the timezone for this `dateTime` value */ - proc dateTime.tzname() { - if timezone.borrow() == nil then - return ""; - return timezone!.tzname(this); - } - - /* Return a filled record matching the C `struct tm` type for the given - `dateTime` */ - @unstable("'dateTime.timetuple' is unstable") - proc dateTime.timetuple() { - var timeStruct: tm; - timeStruct.tm_sec = second: int(32); - timeStruct.tm_min = minute: int(32); - timeStruct.tm_hour = hour: int(32); - timeStruct.tm_mday = day: int(32); - timeStruct.tm_mon = month: int(32); - timeStruct.tm_year = year: int(32); - timeStruct.tm_wday = weekday(): int(32); - timeStruct.tm_yday = (toOrdinal() - (new date(year, 1, 1)).toOrdinal() + 1): int(32); - - if timezone.borrow() == nil { - timeStruct.tm_isdst = -1; - } else if dst() == new timedelta(0) { - timeStruct.tm_isdst = 0; - } else { - timeStruct.tm_isdst = 1; - } - - return timeStruct; - } - - /* Return a filled record matching the C `struct tm` type for the given - `dateTime` in UTC - */ - @unstable("'dateTime.utctimetuple' is unstable") - proc dateTime.utctimetuple() { - if timezone.borrow() == nil { - var ret = timetuple(); - ret.tm_isdst = 0; - return ret; - } else { - const utc = this.replace(tz=nil) - utcOffset(); - var ret = utc.timetuple(); - ret.tm_isdst = 0; - return ret; - } - } - - /* Return the number of days since 1-1-0001 this `dateTime` represents */ - proc dateTime.toOrdinal() { - return getdate().toOrdinal(); - } - - /* Return the day of the week as a `dayOfWeek`. - `Monday` == 0, `Sunday` == 6 - */ - proc dateTime.weekday() { - return getdate().weekday(); - } - - /* Return the day of the week as an `isoDayOfWeek`. - `Monday` == 1, `Sunday` == 7 - */ - proc dateTime.isoWeekday() { - return getdate().isoWeekday(); - } - - - @deprecated(notes="'isoweekday' is deprecated, please use 'isoWeekday' instead") - proc dateTime.isoweekday() { - return isoWeekday(); - } - - /* Return the ISO date as a tuple containing the ISO year, ISO week number, - and ISO day of the week - */ - proc dateTime.isoCalendar() { - return getdate().isoCalendar(); - } - - - @deprecated(notes="'isocalendar' is deprecated, please use 'isoCalendar' instead") - proc dateTime.isocalendar() { - return getdate().isoCalendar(); - } - - /* Return the `dateTime` as a `string` in ISO format */ - proc dateTime.isoFormat(sep="T") { - proc zeroPad(nDigits: int, i: int) { - var numStr = i: string; - for i in 1..nDigits-numStr.size { - numStr = "0" + numStr; - } - return numStr; - } - var micro = if microsecond > 0 then "." + zeroPad(6, microsecond) else ""; - var offset: string; - if timezone.borrow() != nil { - var utcoff = utcOffset(); - var sign: string; - if utcoff < new timedelta(0) { - sign = '-'; - utcoff = abs(utcoff); - } else { - sign = '+'; - } - var hours = utcoff.seconds / (60*60); - var minutes = (utcoff.seconds % (60*60)) / 60; - offset = sign + - (if hours < 10 then "0" + hours: string else hours: string) + - ":" + - (if minutes < 10 then "0" + minutes: string else minutes: string); - } - - // on our Linux64 systems, the "%Y" format doesn't zero-pad to 4 - // characters on its own, so do it manually. - var year = zeroPad(4, try! strftime("%Y"):int); - return strftime(year + "-%m-%d" + sep + "%H:%M:%S" + micro + offset); - } - - /* Create a `dateTime` as described by the `date_string` and - `format` string. Note that this routine currently only supports - the format strings of C's strptime(). - */ - @unstable("'dateTime.strptime' is unstable") - proc type dateTime.strptime(date_string: string, format: string) { - extern proc strptime(buf: c_string, format: c_string, ref ts: tm); - var timeStruct: tm; - strptime(date_string.c_str(), format.c_str(), timeStruct); - return new dateTime(timeStruct.tm_year + 1900, - timeStruct.tm_mon + 1, - timeStruct.tm_mday, - timeStruct.tm_hour, - timeStruct.tm_min, - timeStruct.tm_sec); - } - - /* Create a `string` from a `dateTime` matching the `format` string */ - @unstable("'dateTime.strftime' is unstable") - proc dateTime.strftime(fmt: string) { - extern proc strftime(s: c_void_ptr, size: c_size_t, format: c_string, ref timeStruct: tm); - const bufLen: c_size_t = 100; - var buf: [1..bufLen] c_char; - var timeStruct: tm; - - timeStruct.tm_hour = hour: int(32); - timeStruct.tm_min = minute: int(32); - timeStruct.tm_sec = second: int(32); - - if timezone.borrow() != nil { - timeStruct.tm_isdst = timezone!.dst(this).seconds: int(32); - timeStruct.tm_gmtoff = timezone!.utcOffset(this).seconds: c_long; - timeStruct.tm_zone = nil; - } else { - timeStruct.tm_isdst = -1: int(32); - timeStruct.tm_gmtoff = 0; - timeStruct.tm_zone = nil; - } - - timeStruct.tm_year = (year-1900): int(32); // 1900 based - timeStruct.tm_mon = (month-1): int(32); // 0 based - timeStruct.tm_mday = day: int(32); - timeStruct.tm_wday = (weekday(): int(32) + 1) % 7; // shift Sunday to 0 - timeStruct.tm_yday = (this.replace(tz=nil) - new dateTime(year, 1, 1)).days: int(32); - - // Iterate over format specifiers in strftime(), replacing %f with microseconds - iter strftok(const ref s: string) - { - var per = ""; - for c in s { - if per == "" { - if c == '%' { - per = "%"; - } else { - yield c; - } - } else { - per += c; - - // Modifiers - (no padding) 0 (0-padding) _ (space padding) E and O (POSIX extensions) - if per != '%-' && per != '%0' && per != '%_' && per != '%E' && per != '%O' { - if c == "f" { - const fmt = if per == "%-f" then "%i" else if per == "%_f" then "%6i" else "%06i"; - try! { - yield fmt.format(chpl_time.chpl_microsecond); - } - } else { - yield per; - } - per = ""; - } - } - } - if per != "" { - yield per; - } - } - - strftime(c_ptrTo(buf), bufLen, "".join(strftok(fmt)).c_str(), timeStruct); - - var str: string; - try! { - str = string.createCopyingBuffer(c_ptrTo(buf):c_string); - } - - return str; - } - - /* Return a `string` from a `dateTime` in the form: - Wed Dec 4 20:30:40 2002 - */ - @unstable("'dateTime.ctime' is unstable") - proc dateTime.ctime() { - return this.strftime("%a %b %e %T %Y"); - } - - /* Writes this `dateTime` in ISO format: YYYY-MM-DDThh:mm:ss.sss */ - proc dateTime.writeThis(f) throws { - f.write(isoFormat()); - } - - /* Reads this `dateTime` from ISO format: YYYY-MM-DDThh:mm:ss.sss */ - proc dateTime.readThis(f) throws { - const binary = f.binary(), - arrayStyle = f.styleElement(QIO_STYLE_ELEMENT_ARRAY), - isjson = arrayStyle == QIO_ARRAY_FORMAT_JSON && !binary; - - if isjson then - f._readLiteral('"'); - - chpl_date._readCore(f); - f._readLiteral("T"); - chpl_time._readCore(f); - - if isjson then - f._readLiteral('"'); - } - - // - // TODO: need to get this to work with the Json formatter - // - - proc dateTime.init(f: fileReader) { - this.init(); - readThis(f); - } - - - // TODO: Add a dateTime.timestamp() method - - /* Operators on dateTime values */ - - - operator dateTime.+(td: timedelta, dt: dateTime) { - var newmicro = dt.microsecond + td.microseconds; - var newsec = dt.second + td.seconds; - var newmin = dt.minute; - var newhour = dt.hour; - - // adjust to fit - newsec += newmicro / 1000000; - newmicro %= 1000000; - - newmin += newsec / 60; - newsec %= 60; - - newhour += newmin / 60; - newmin %= 60; - - var adddays = td.days + newhour / 24; - newhour %= 24; - - return dateTime.combine(date.fromOrdinal(dt.getdate().toOrdinal()+adddays), - new time(hour=newhour, minute=newmin, - second=newsec, microsecond=newmicro, - tz=dt.timezone)); - - } - - - operator dateTime.+(dt: dateTime, td: timedelta) { - return td + dt; - } - - - operator dateTime.-(dt: dateTime, td: timedelta) { - var deltasec = td.seconds % 60; - var deltamin = (td.seconds / 60) % 60; - var deltahour = td.seconds / (60*60); - - var newmicro = dt.microsecond - td.microseconds; - var newsec = dt.second - deltasec; - var newmin = dt.minute - deltamin; - var newhour = dt.hour - deltahour; - - var subDays = td.days; - - if newmicro < 0 { - newsec -= 1; - newmicro += 1000000; - } - if newsec < 0 { - newmin -= 1; - newsec += 60; - } - if newmin < 0 { - newhour -= 1; - newmin += 60; - } - if newhour < 0 { - subDays += 1; - newhour += 24; - } - return dateTime.combine(date.fromOrdinal(dt.getdate().toOrdinal()-subDays), - new time(hour=newhour, minute=newmin, - second=newsec, microsecond=newmicro, - tz=dt.timezone)); - } - - - operator dateTime.-(dt1: dateTime, dt2: dateTime): timedelta { - if (dt1.timezone.borrow() != nil && dt2.timezone.borrow() == nil) || - (dt1.timezone.borrow() == nil && dt2.timezone.borrow() != nil) { - halt("both dateTimes must both be either naive or aware"); - } - if dt1.timezone == dt2.timezone { - const newmicro = dt1.microsecond - dt2.microsecond, - newsec = dt1.second - dt2.second, - newmin = dt1.minute - dt2.minute, - newhour = dt1.hour - dt2.hour, - newday = dt1.toOrdinal() - dt2.toOrdinal(); - return new timedelta(days=newday, hours=newhour, minutes=newmin, - seconds=newsec, microseconds=newmicro); - } else { - return dt1.replace(tz=nil) - - dt2.replace(tz=nil) + - dt2.utcOffset() - dt1.utcOffset(); - } - } - - - operator dateTime.==(dt1: dateTime, dt2: dateTime): bool { - if dt1.timezone.borrow() == nil && dt2.timezone.borrow() != nil || - dt1.timezone.borrow() != nil && dt2.timezone.borrow() == nil { - halt("Cannot compare naive dateTime to aware dateTime"); - } else if dt1.timezone == dt2.timezone { - // just ignore timezone - var d1: date = dt1.replace(tz=nil).getdate(), - d2: date = dt2.replace(tz=nil).getdate(); - var t1: time = dt1.replace(tz=nil).gettime(), - t2: time = dt2.replace(tz=nil).gettime(); - - return d1.year == d2.year && d1.month == d2.month && d1.day == d2.day && - t1.hour == t2.hour && t1.minute == t2.minute && - t1.second == t2.second && - t1.microsecond == t2.microsecond; - } else { - return (dt1.replace(tz=nil) - dt1.utcOffset()) == - (dt2.replace(tz=nil) - dt2.utcOffset()); - } - } - - - operator dateTime.!=(dt1: dateTime, dt2: dateTime) { - return !(dt1 == dt2); - } - - - operator dateTime.<(dt1: dateTime, dt2: dateTime): bool { - if (dt1.timezone.borrow() != nil && dt2.timezone.borrow() == nil) || - (dt1.timezone.borrow() == nil && dt2.timezone.borrow() != nil) { - halt("both dateTimes must both be either naive or aware"); - } else if dt1.timezone == dt2.timezone { - const date1 = dt1.getdate(), - date2 = dt2.getdate(); - if date1 < date2 then return true; - else if date2 < date1 then return false; - else return dt1.gettime() < dt2.gettime(); - } else { - return (dt1.replace(tz=nil) - dt1.utcOffset()) < - (dt2.replace(tz=nil) - dt2.utcOffset()); - } - } - - - operator dateTime.<=(dt1: dateTime, dt2: dateTime): bool { - if (dt1.timezone.borrow() != nil && dt2.timezone.borrow() == nil) || - (dt1.timezone.borrow() == nil && dt2.timezone.borrow() != nil) { - halt("both dateTimes must both be either naive or aware"); - } else if dt1.timezone == dt2.timezone { - const date1 = dt1.getdate(), - date2 = dt2.getdate(); - if date1 < date2 then return true; - else if date2 < date1 then return false; - else return dt1.gettime() <= dt2.gettime(); - } else { - return (dt1.replace(tz=nil) - dt1.utcOffset()) <= - (dt2.replace(tz=nil) - dt2.utcOffset()); - } - } - - - operator dateTime.>(dt1: dateTime, dt2: dateTime): bool { - if (dt1.timezone.borrow() != nil && dt2.timezone.borrow() == nil) || - (dt1.timezone.borrow() == nil && dt2.timezone.borrow() != nil) { - halt("both dateTimes must both be either naive or aware"); - } else if dt1.timezone == dt2.timezone { - const date1 = dt1.getdate(), - date2 = dt2.getdate(); - if date1 > date2 then return true; - else if date2 > date1 then return false; - else return dt1.gettime() > dt2.gettime(); - } else { - return (dt1.replace(tz=nil) - dt1.utcOffset()) > - (dt2.replace(tz=nil) - dt2.utcOffset()); - } - } - - - operator dateTime.>=(dt1: dateTime, dt2: dateTime): bool { - if (dt1.timezone.borrow() != nil && dt2.timezone.borrow() == nil) || - (dt1.timezone.borrow() == nil && dt2.timezone.borrow() != nil) { - halt("both dateTimes must both be either naive or aware"); - } else if dt1.timezone == dt2.timezone { - const date1 = dt1.getdate(), - date2 = dt2.getdate(); - if date1 > date2 then return true; - else if date2 > date1 then return false; - else return dt1.gettime() >= dt2.gettime(); - } else { - return (dt1.replace(tz=nil) - dt1.utcOffset()) >= - (dt2.replace(tz=nil) - dt2.utcOffset()); - } - } - - - - /* A record representing an amount of time. A `timedelta` has fields - representing days, seconds, and microseconds. These fields are always - kept within the following ranges: - - 0 <= `microseconds` < 1000000 - - 0 <= `seconds` < 60*60*24 - - -999999999 <= `days` <= 999999999 - - It is an overflow error if `days` is outside the given range. - */ - record timedelta { - - var chpl_days: int; - - - var chpl_seconds: int; - - - var chpl_microseconds: int; - - /* The number of days this `timedelta` represents */ - proc days { - return chpl_days; - } - - /* The number of seconds this `timedelta` represents */ - proc seconds { - return chpl_seconds; - } - - /* The number of microseconds this `timedelta` represents */ - proc microseconds { - return chpl_microseconds; - } - - /* Return the minimum representable `timedelta` object. */ - proc type min { - return new timedelta(days=-999999999); - } - - /* Return the maximum representable `timedelta` object. */ - proc type max { - return new timedelta(days=999999999, hours=23, minutes=59, - seconds=59, microseconds=999999); - } - - /* Return the smallest positive value representable by a `timedelta` - object. - */ - proc type resolution { - return new timedelta(microseconds=1); - } - } - - /* initializers/factories for timedelta values */ - - /* Initialize a `timedelta` object. All arguments are optional and - default to 0. Since only `days`, `seconds` and `microseconds` are - stored, the other arguments are converted to days, seconds - and microseconds. */ - proc timedelta.init(days:int=0, seconds:int=0, microseconds:int=0, - milliseconds:int=0, minutes:int=0, hours:int=0, weeks:int=0) { - param usps = 1000000, // microseconds per second - uspms = 1000, // microseconds per millisecond - spd = 24*60*60; // seconds per day - - // us/sec sec/min min/hour - // | | | - var us = usps * ((60 * (hours*60 + minutes)) + seconds) + - uspms * milliseconds + microseconds; - var sec = us / usps; - us = us % usps; - - if us < 0 { - sec -= 1; - us = usps + us; - } - var day = weeks*7 + days + sec / spd; - sec = sec % (spd); - - if sec < 0 { - day -= 1; - sec = spd + sec; - } - - this.chpl_days = day; - this.chpl_seconds = sec; - this.chpl_microseconds = us; - - if this.days < -999999999 then - HaltWrappers.initHalt("Overflow: days < -999999999"); - - if this.days > 999999999 then - HaltWrappers.initHalt("Overflow: days > 999999999"); - } - - /* Create a `timedelta` from a given number of seconds */ - proc timedelta.init(timestamp: real) { - this.init(seconds = timestamp: int, microseconds=((timestamp - timestamp: int)*1000000): int); - } - - - /* Methods on timedelta values */ - - /* Return the total number of seconds represented by this object */ - proc timedelta.totalSeconds(): real { - return days*(24*60*60) + seconds + microseconds / 1000000.0; - } - - - /* Operators on timedelta values */ - - - operator timedelta.*(i: int, t: timedelta) { - return new timedelta(days=i*t.days, seconds=i*t.seconds, microseconds=i*t.microseconds); - } - - - operator timedelta.*(t: timedelta, i: int) { - return new timedelta(days=i*t.days, seconds=i*t.seconds, microseconds=i*t.microseconds); - } - - - operator timedelta./(t: timedelta, i: int) { - var day = t.days / i; - var second = t.seconds + (t.days % i)*24*60*60; - var microsecond = t.microseconds + (second % i)*1000000; - var us_remainder = microsecond % i; - second /= i; - microsecond /= i; - - if us_remainder*2 >= i then - microsecond += 1; // round up - - return new timedelta(days=day, seconds=second, microseconds=microsecond); - } - - - operator timedelta.+(t: timedelta) { - return t; - } - - - operator timedelta.-(t: timedelta) { - return new timedelta(days=-t.days, seconds=-t.seconds, microseconds=-t.microseconds); - } - - - operator timedelta.+(lhs: timedelta, rhs: timedelta) { - return new timedelta(days=lhs.days+rhs.days, - seconds=lhs.seconds+rhs.seconds, - microseconds=lhs.microseconds+rhs.microseconds); - } - - - operator timedelta.-(lhs: timedelta, rhs: timedelta) { - return new timedelta(days=lhs.days-rhs.days, - seconds=lhs.seconds-rhs.seconds, - microseconds=lhs.microseconds-rhs.microseconds); - } - - - operator timedelta.>(lhs: timedelta, rhs: timedelta) { - const ls = (lhs.days*(24*60*60) + lhs.seconds); - const rs = (rhs.days*(24*60*60) + rhs.seconds); - if ls > rs then return true; - if rs > ls then return false; - return lhs.microseconds > rhs.microseconds; - } - - - operator timedelta.>=(lhs: timedelta, rhs: timedelta) { - return lhs > rhs || lhs == rhs; - } - - - operator timedelta.<(lhs: timedelta, rhs: timedelta) { - const ls = (lhs.days*(24*60*60) + lhs.seconds); - const rs = (rhs.days*(24*60*60) + rhs.seconds); - if ls < rs then return true; - if rs < ls then return false; - return lhs.microseconds < rhs.microseconds; - } - - - operator timedelta.<=(lhs: timedelta, rhs: timedelta) { - return lhs < rhs || lhs == rhs; - } - - /* Return the absolute value of `t`. If `t` is negative, then returns `-t`, - else returns `t`. - */ - proc abs(t: timedelta) { - if t.days < 0 then - return -t; - else - return t; - } - - - operator :(t: timedelta, type s:string) { - var str: string; - if t.days != 0 { - str = t.days: string + " day"; - if t.days != 1 && t.days != -1 then - str += "s"; - str += ", "; - } - const seconds = t.seconds % 60; - const minutes = (t.seconds / 60) % 60; - const hours = t.seconds / (60*60); - const microseconds = t.microseconds; - - str += hours: string + ":"; - if minutes < 10 then - str += "0"; - str += minutes + ":"; - if seconds < 10 then - str += "0"; - str += seconds; - if microseconds != 0 { - str += "."; - const usLog10 = log10(microseconds): int; - for i in 1..(5-usLog10) { - str += "0"; - } - - str += microseconds: string; - } - return str; - } - - - @deprecated(notes="'TZInfo' is deprecated, please use 'Timezone' instead") - class TZInfo: Timezone { } - - /* Abstract base class for time zones. This class should not be used - directly, but concrete implementations of time zones should be - derived from it. */ - class Timezone { - /* The offset from UTC this class represents */ - proc utcOffset(dt: dateTime): timedelta { - HaltWrappers.pureVirtualMethodHalt(); - return new timedelta(); - } - - /* The `timedelta` for daylight saving time */ - proc dst(dt: dateTime): timedelta { - HaltWrappers.pureVirtualMethodHalt(); - return new timedelta(); - } - - /* The name of this time zone */ - proc tzname(dt: dateTime): string { - HaltWrappers.pureVirtualMethodHalt(); - return ""; - } - - /* Convert a `time` in UTC to this time zone */ - proc fromUtc(dt: dateTime): dateTime { - HaltWrappers.pureVirtualMethodHalt(); - return new dateTime(0,0,0); - } - - } - - // TODO: Add a timezone class implementation - - -/* - :arg unit: The units for the returned value - :type unit: :type:`TimeUnits` - - :returns: The elapsed time since midnight, local time, in the units specified - :rtype: `real(64)` - */ -@deprecated(notes="'getCurrentTime()' is deprecated please use 'timeSinceEpoch().totalSeconds()' instead") -proc getCurrentTime(unit: TimeUnits = TimeUnits.seconds) : real(64) do - return _convert_microseconds(unit, chpl_now_time()); - -/* - :returns: (year, month, day) as a tuple of 3 ints - - The month is in the range 1 to 12. - The day is in the range 1 to 31 -*/ -proc getCurrentDate() { - var now = chpl_now_timevalue(); - - var seconds, minutes, hours, mday, month, year, wday, yday, isdst:int(32); - - chpl_timevalue_parts(now, seconds, minutes, hours, mday, month, year, wday, yday, isdst); - - return (year + 1900, month + 1, mday); -} - -/* - :returns: The current day of the week - :rtype: :type:`Day` - */ -proc getCurrentDayOfWeek() : Day { - var now = chpl_now_timevalue(); - - var seconds, minutes, hours, mday, month, year, wday, yday, isdst:int(32); - - chpl_timevalue_parts(now, seconds, minutes, hours, mday, month, year, wday, yday, isdst); - - return try! wday : Day; -} - -/* - Delay a task for a duration in the units specified. This function - will return without sleeping and emit a warning if the duration is - negative. - - :arg t: The duration for the time to sleep - :type t: `real` - - :arg unit: The units for the duration - :type unit: :type:`TimeUnits` -*/ -@deprecated(notes="'sleep' with a 'TimeUnits' argument is deprecated. Please use 'sleep' with a time in seconds") -inline proc sleep(t: real, unit: TimeUnits) : void { - use CTypes; - extern proc chpl_task_sleep(s:c_double) : void; - - if t < 0 { - warning("sleep() called with negative time parameter: '", t, "'"); - return; - } - chpl_task_sleep(_convert_to_seconds(unit, t:real):c_double); -} - -/* - Delay a task for a duration specified in seconds. This function - will return without sleeping and emit a warning if the duration is - negative. - - :arg t: The duration for the time to sleep - :type t: `real` -*/ -inline proc sleep(t: real) : void { - use CTypes; - extern proc chpl_task_sleep(s:c_double) : void; - - if t < 0 { - warning("sleep() called with negative time parameter: '", t, "'"); - return; - } - chpl_task_sleep(t:c_double); -} - -/* - Implements basic stopwatch behavior with a potential resolution of - microseconds if supported by the runtime platform. - - The :record:`!stopwatch` can be started, stopped, and cleared. - A :record:`!stopwatch` is either running or stopped. -*/ -record stopwatch { - - var time: _timevalue = chpl_null_timevalue(); - - - var accumulated: real = 0.0; - - - var running: bool = false; - - /* - Clears the elapsed time. If the timer is running then it is restarted - otherwise it remains in the stopped state. - */ - proc clear() : void { - accumulated = 0.0; - - if running { - time = chpl_now_timevalue(); - } - } - - /* Starts the timer. A warning is emitted if the timer is already running. */ - proc start() : void { - if !running { - running = true; - time = chpl_now_timevalue(); - } else { - warning("start called on a timer that has not been stopped"); - } - } - - /* Stops the timer. A warning is emitted if the timer is not running. */ - proc stop() : void { - if running { - var time2: _timevalue = chpl_now_timevalue(); - - accumulated += _diff_time(time2, time); - running = false; - } else { - warning("stop called on a timer that has not been started"); - } - } - - /* Clear the elapsed time and ensure the stopwatch is stopped */ - proc reset() { - if running { - stop(); - } - clear(); - } - - /* Clear the elapsed time and ensure the stopwatch is running */ - proc restart() { - clear(); - if !running { - start(); - } - } - - /* - Returns the cumulative elapsed time, in the units specified, between - all pairs of calls to :proc:`start` and :proc:`stop` - since the timer was created or the last call to :proc:`clear`. - If the timer is running, the elapsed time since the last call to - :proc:`start` is added to the return value. - - :arg unit: The units for the returned value - :type unit: :type:`TimeUnits` - - :returns: The elapsed time in the units specified - :rtype: `real(64)` - */ - @deprecated(notes="'stopwatch.elapsed' with a 'TimeUnits' argument is deprecated. Please call 'stopwatch.elapsed' without an argument and assume it returns a time in seconds.") - proc elapsed(unit: TimeUnits) : real { - if running { - var time2: _timevalue = chpl_now_timevalue(); - - return _convert_microseconds(unit, accumulated + _diff_time(time2, time)); - } else { - return _convert_microseconds(unit, accumulated); - } - } - - /* - Returns the cumulative elapsed time, in seconds, between - all pairs of calls to :proc:`start` and :proc:`stop` - since the timer was created or the last call to :proc:`clear`. - If the timer is running, the elapsed time since the last call to - :proc:`start` is added to the return value. - - :returns: The elapsed time in seconds - :rtype: `real(64)` - */ - proc elapsed() : real { - if running { - var time2: _timevalue = chpl_now_timevalue(); - - return (accumulated + _diff_time(time2, time)) / 1.0e+6; - } else { - return accumulated / 1.0e+6; - } - } -} - -@deprecated(notes="'Timer' is deprecated, please use 'stopwatch' instead") -record Timer { - - var time: _timevalue = chpl_null_timevalue(); - - - var accumulated: real = 0.0; - - - var running: bool = false; - - /* - Clears the elapsed time. If the timer is running then it is restarted - otherwise it remains in the stopped state. - */ - proc clear() : void { - accumulated = 0.0; - - if running { - time = chpl_now_timevalue(); - } - } - - /* Starts the timer. A warning is emitted if the timer is already running. */ - proc start() : void { - if !running { - running = true; - time = chpl_now_timevalue(); - } else { - warning("start called on a timer that has not been stopped"); - } - } - - /* Stops the timer. A warning is emitted if the timer is not running. */ - proc stop() : void { - if running { - var time2: _timevalue = chpl_now_timevalue(); - - accumulated += _diff_time(time2, time); - running = false; - } else { - warning("stop called on a timer that has not been started"); - } - } - - /* - Returns the cumulative elapsed time, in the units specified, between - all pairs of calls to :proc:`start` and :proc:`stop` - since the timer was created or the last call to :proc:`clear`. - If the timer is running, the elapsed time since the last call to - :proc:`start` is added to the return value. - - :arg unit: The units for the returned value - :type unit: :type:`TimeUnits` - - :returns: The elapsed time in the units specified - :rtype: `real(64)` - */ - @deprecated(notes="'Timer.elapsed' with a 'TimeUnits' argument is deprecated. Please call 'stopwatch.elapsed' without an argument and assume it returns a time in seconds.") - proc elapsed(unit: TimeUnits = TimeUnits.seconds) : real { - if running { - var time2: _timevalue = chpl_now_timevalue(); - - return _convert_microseconds(unit, accumulated + _diff_time(time2, time)); - } else { - return _convert_microseconds(unit, accumulated); - } - } -} - -// returns diff of two time values in microseconds -private inline proc _diff_time(t1: _timevalue, t2: _timevalue) { - extern proc chpl_timevalue_seconds(t:_timevalue): int(64); - extern proc chpl_timevalue_microseconds(t:_timevalue): int(64); - - var s1 = chpl_timevalue_seconds(t1); - var us1 = chpl_timevalue_microseconds(t1); - - var s2 = chpl_timevalue_seconds(t2); - var us2 = chpl_timevalue_microseconds(t2); - - return (s1 * 1.0e+6 + us1) - (s2 * 1.0e+6 + us2); -} - -// converts a time specified by unit into seconds -@deprecated(notes="'_convert_to_seconds' is deprecated without replacement") -private proc _convert_to_seconds(unit: TimeUnits, us: real) { - select unit { - when TimeUnits.microseconds do return us * 1.0e-6; - when TimeUnits.milliseconds do return us * 1.0e-3; - when TimeUnits.seconds do return us; - when TimeUnits.minutes do return us * 60.0; - when TimeUnits.hours do return us * 3600.0; - } - - HaltWrappers.exhaustiveSelectHalt("unknown timeunits type"); - return -1.0; -} - -// converts microseconds to another unit -@deprecated(notes="'_convert_microseconds' is deprecated without replacement") -private proc _convert_microseconds(unit: TimeUnits, us: real) { - select unit { - when TimeUnits.microseconds do return us; - when TimeUnits.milliseconds do return us / 1.0e+3; - when TimeUnits.seconds do return us / 1.0e+6; - when TimeUnits.minutes do return us / 60.0e+6; - when TimeUnits.hours do return us / 3600.0e+6; - } - - HaltWrappers.exhaustiveSelectHalt("unknown timeunits type"); - return -1.0; -} - -} diff --git a/src/compat/e-130/SymArrayDmapCompat.chpl b/src/compat/e-130/SymArrayDmapCompat.chpl deleted file mode 100644 index d2ca244507..0000000000 --- a/src/compat/e-130/SymArrayDmapCompat.chpl +++ /dev/null @@ -1,95 +0,0 @@ - -module SymArrayDmapCompat -{ - use ChplConfig; - - /* - Available domain maps. - */ - enum Dmap {defaultRectangular, blockDist}; - - private param defaultDmap = if CHPL_COMM == "none" then Dmap.defaultRectangular - else Dmap.blockDist; - /* - How domains/arrays are distributed. Defaults to :enum:`Dmap.defaultRectangular` if - :param:`CHPL_COMM=none`, otherwise defaults to :enum:`Dmap.blockDist`. - */ - config param MyDmap:Dmap = defaultDmap; - - public use BlockDist; - - /* - Makes a domain distributed according to :param:`MyDmap`. - - :arg size: size of domain - :type size: int - */ - proc makeDistDom(size:int) { - select MyDmap - { - when Dmap.defaultRectangular { - return {0..#size}; - } - when Dmap.blockDist { - if size > 0 { - return {0..#size} dmapped Block(boundingBox={0..#size}); - } - // fix the annoyance about boundingBox being enpty - else {return {0..#0} dmapped Block(boundingBox={0..0});} - } - otherwise { - halt("Unsupported distribution " + MyDmap:string); - } - } - } - - /* - Makes an array of specified type over a distributed domain - - :arg size: size of the domain - :type size: int - - :arg etype: desired type of array - :type etype: type - - :returns: [] ?etype - */ - proc makeDistArray(size:int, type etype) { - var a: [makeDistDom(size)] etype; - return a; - } - - proc makeDistArray(in a: [?D] ?etype) - where MyDmap != Dmap.defaultRectangular && a.isDefaultRectangular() { - var res = makeDistArray(D.size, etype); - res = a; - return res; - } - - proc makeDistArray(in a: [?D] ?etype) { - return a; - } - - proc makeDistArray(D: domain, type etype) { - var res: [D] etype; - return res; - } - - proc makeDistArray(D: domain, initExpr: ?t) throws { - var res: [D] t = initExpr; - return res; - } - - /* - Returns the type of the distributed domain - - :arg size: size of domain - :type size: int - - :returns: type - */ - proc makeDistDomType(size: int) type { - return makeDistDom(size).type; - } - -} diff --git a/src/compat/eq-131/ArkoudaArrayCompat.chpl b/src/compat/eq-131/ArkoudaArrayCompat.chpl deleted file mode 100644 index 2600e79c0c..0000000000 --- a/src/compat/eq-131/ArkoudaArrayCompat.chpl +++ /dev/null @@ -1,2 +0,0 @@ -module ArkoudaArrayCompat { -} diff --git a/src/compat/eq-131/ArkoudaBitOpsCompat.chpl b/src/compat/eq-131/ArkoudaBitOpsCompat.chpl deleted file mode 100644 index 0b02bc334a..0000000000 --- a/src/compat/eq-131/ArkoudaBitOpsCompat.chpl +++ /dev/null @@ -1 +0,0 @@ -module ArkoudaBitOpsCompat { } diff --git a/src/compat/eq-131/ArkoudaListCompat.chpl b/src/compat/eq-131/ArkoudaListCompat.chpl deleted file mode 100644 index e0df830e9c..0000000000 --- a/src/compat/eq-131/ArkoudaListCompat.chpl +++ /dev/null @@ -1 +0,0 @@ -module ArkoudaListCompat { } diff --git a/src/compat/eq-131/ArkoudaStringBytesCompat.chpl b/src/compat/eq-131/ArkoudaStringBytesCompat.chpl deleted file mode 100644 index 0981717d36..0000000000 --- a/src/compat/eq-131/ArkoudaStringBytesCompat.chpl +++ /dev/null @@ -1 +0,0 @@ -module ArkoudaStringBytesCompat {} diff --git a/src/compat/gt-131/ArkoudaArrayCompat.chpl b/src/compat/gt-131/ArkoudaArrayCompat.chpl deleted file mode 100644 index 2600e79c0c..0000000000 --- a/src/compat/gt-131/ArkoudaArrayCompat.chpl +++ /dev/null @@ -1,2 +0,0 @@ -module ArkoudaArrayCompat { -} diff --git a/src/compat/gt-131/ArkoudaBitOpsCompat.chpl b/src/compat/gt-131/ArkoudaBitOpsCompat.chpl deleted file mode 100644 index 0b02bc334a..0000000000 --- a/src/compat/gt-131/ArkoudaBitOpsCompat.chpl +++ /dev/null @@ -1 +0,0 @@ -module ArkoudaBitOpsCompat { } diff --git a/src/compat/gt-131/ArkoudaListCompat.chpl b/src/compat/gt-131/ArkoudaListCompat.chpl deleted file mode 100644 index e0df830e9c..0000000000 --- a/src/compat/gt-131/ArkoudaListCompat.chpl +++ /dev/null @@ -1 +0,0 @@ -module ArkoudaListCompat { } diff --git a/src/compat/gt-131/ArkoudaStringBytesCompat.chpl b/src/compat/gt-131/ArkoudaStringBytesCompat.chpl deleted file mode 100644 index 0981717d36..0000000000 --- a/src/compat/gt-131/ArkoudaStringBytesCompat.chpl +++ /dev/null @@ -1 +0,0 @@ -module ArkoudaStringBytesCompat {} diff --git a/tests/server/UnitTestParquetCpp.chpl b/tests/server/UnitTestParquetCpp.chpl index ebc12d07f4..9cae4c38d2 100644 --- a/tests/server/UnitTestParquetCpp.chpl +++ b/tests/server/UnitTestParquetCpp.chpl @@ -1,7 +1,6 @@ use ParquetMsg, CTypes, FileSystem; use UnitTest; use TestBase; -use ArkoudaStringBytesCompat; proc testReadWrite(filename: c_string, dsetname: c_string, size: int) { extern proc c_readColumnByName(filename, chpl_arr, colNum, numElems, startIdx, batchSize, errMsg): int;