Skip to content

Conversation

@klausler
Copy link
Contributor

@klausler klausler commented Sep 6, 2024

Don't require the "VALUES=" argument to the extension intrinsic procedure ETIME to have exactly two elements. Other compilers that support ETIME do not, and it's easy to adapt the behavior to whatever the dynamic size turns out to be.

Don't require the "VALUES=" argument to the extension intrinsic procedure
ETIME to have exactly two elements.  Other compilers that support ETIME
do not, and it's easy to adapt the behavior to whatever the dynamic size
turns out to be.
@klausler klausler requested a review from jeanPerier September 6, 2024 22:04
@llvmbot llvmbot added flang:runtime flang Flang issues not falling into any other category labels Sep 6, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 6, 2024

@llvm/pr-subscribers-flang-runtime

Author: Peter Klausler (klausler)

Changes

Don't require the "VALUES=" argument to the extension intrinsic procedure ETIME to have exactly two elements. Other compilers that support ETIME do not, and it's easy to adapt the behavior to whatever the dynamic size turns out to be.


Full diff: https://github.com/llvm/llvm-project/pull/107647.diff

1 Files Affected:

  • (modified) flang/runtime/time-intrinsic.cpp (+11-7)
diff --git a/flang/runtime/time-intrinsic.cpp b/flang/runtime/time-intrinsic.cpp
index 7e590eabf39660..e6f6e81c7b50cc 100644
--- a/flang/runtime/time-intrinsic.cpp
+++ b/flang/runtime/time-intrinsic.cpp
@@ -490,16 +490,20 @@ void RTNAME(Etime)(const Descriptor *values, const Descriptor *time,
     auto typeCode{values->type().GetCategoryAndKind()};
     // ETIME values argument must have decimal range == 2.
     RUNTIME_CHECK(terminator,
-        values->rank() == 1 && values->GetDimension(0).Extent() == 2 &&
-            typeCode && typeCode->first == Fortran::common::TypeCategory::Real);
+        values->rank() == 1 && typeCode &&
+            typeCode->first == Fortran::common::TypeCategory::Real);
     // Only accept KIND=4 here.
     int kind{typeCode->second};
     RUNTIME_CHECK(terminator, kind == 4);
-
-    ApplyFloatingPointKind<StoreFloatingPointAt, void>(
-        kind, terminator, *values, /* atIndex = */ 0, usrTime);
-    ApplyFloatingPointKind<StoreFloatingPointAt, void>(
-        kind, terminator, *values, /* atIndex = */ 1, sysTime);
+    auto extent{values->GetDimension(0).Extent()};
+    if (extent >= 1) {
+      ApplyFloatingPointKind<StoreFloatingPointAt, void>(
+          kind, terminator, *values, /* atIndex = */ 0, usrTime);
+    }
+    if (extent >= 2) {
+      ApplyFloatingPointKind<StoreFloatingPointAt, void>(
+          kind, terminator, *values, /* atIndex = */ 1, sysTime);
+    }
   }
 
   if (time) {

@klausler klausler merged commit fe58527 into llvm:main Sep 10, 2024
@klausler klausler deleted the fs36391 branch September 10, 2024 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:runtime flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants