CPU_TIME takes a single real scalar INTENT(OUT) argument. We can
therefore return a double and let lowering handle casting that to the
precision used for the default real kind.
Details
- Reviewers
klausler jeanPerier - Commits
- rG35b0ddab0ee8: [flang] Define the API for CPU_TIME
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
flang/runtime/time-intrinsic.h | ||
---|---|---|
22 | IIUC, the default real kind is usually 4, but can be set to 8 with -fdefault-real-8. Should we have another overload for CppTypeFor<TypeCategory::Real, 4>, or can we assume that lowering can deal with downcasting if the default kind is 4? |
flang/runtime/time-intrinsic.h | ||
---|---|---|
22 | Lowering handles cases which require floating-point format conversions when calling the runtime. That said, the runtime can (and often does) provide multiple interfaces, which may eliminate the necessity of such conversions. |
flang/runtime/time-intrinsic.h | ||
---|---|---|
13 | I would consider putting this into the header file with miscellaneous intrinsics... were it not for the problem of SYSTEM_CLOCK (16.9.186), which will also need a home, and whose API might be messy. DATE_AND_TIME will also need to go here. | |
22 | Lowering can handle data conversions for value arguments and for function results, but reference arguments like CPU_TIME's are somewhat more problematic. CPU_TIME (16.9.57) is a subroutine, not a function. But since its sole argument is INTENT(OUT), the API could be a function returning a C double, and lowering could take care of converting and assigning the result. | |
23 | These source position arguments are needed only for runtime APIs that can encounter errors. CPU_TIME probably can't. |
flang/runtime/time-intrinsic.h | ||
---|---|---|
13 | Yes, my intention was to add SYSTEM_CLOCK here as well. As you point out, DATE_AND_TIME also fits. | |
22 | Ok, for the sake of simplicity we can go with returning a double (although that trick won't work for SYSTEM_CLOCK, where we need 3 output parameters; but that's a different patch). | |
23 | Ok, removing them. |
LGTM
flang/runtime/time-intrinsic.h | ||
---|---|---|
13 | FYI, there is an old draft of DATE_AND_TIME in fir-dev: https://github.com/flang-compiler/f18-llvm-project/blob/fir-dev/flang/runtime/clock.h and https://github.com/flang-compiler/f18-llvm-project/blob/fir-dev/flang/runtime/clock.cpp. |
I would consider putting this into the header file with miscellaneous intrinsics... were it not for the problem of SYSTEM_CLOCK (16.9.186), which will also need a home, and whose API might be messy. DATE_AND_TIME will also need to go here.