Branch: refs/heads/master
Revision: e5c664e
Author: e-kayrakli
Log Message:
Merge pull request #16278 from e-kayrakli/refactor-underscore-handling
Improve string to numerical casts’ compilation and execution performance
This PR contains several improvements to string to numerical type casts mainly
motivated by reducing the generated code size.
Follow on to https://github.com/chapel-lang/chapel/pull/16266
-
Change
_cleanupStringForRealCastto_cleanupStringForNumericCastand use
it for casts to both integers and reals.This reduces the amount of code in the integer casts by a significant amount.
For Arkouda (quickstart local Chapel, ARKOUDA_QUICK_COMPILE=1), we have the
following generated code sizes:
| version | Total LOC |
|---|---|
| master | 1366355 |
| This PR | 1217989 |
This is because the inlined string->int cast has a logic with several
high-level string functions and iterators that are also inlined. This causes
serious code bloat and compiler performance degradation. These calls are now
in a non-inlined _cleanupStringForNumericCast
-
While making that change, use a simpler approach to make some checks to get
some performance.realandimagcasts are about 2.3-2.6 sec range today,
and with this change it is about 2.0-2.3 sec. -
While making that change, fix a bug where we erroneously allowed
" 12 _":real. This cast was correctly not allowed if the type isint.
Also, add a test to lock that behavior. -
This change adds a function call overhead in integer casts. Currently, we get
about 0.6 sec in the relevant benchmark, where the function call brought us to
about 1.0 sec. So, I removed an extra memory allocation in the runtime
implementation of the integer casts. We still pay for the function call, but
this brings us to about 0.4 sec for integer casts.See: https://github.com/chapel-lang/chapel/pull/12097/files#r249146382
I also wanted to take a step to fix
https://github.com/Cray/chapel-private/issues/654, but I think that should be
handled under the umbrella of “how to pass strings to externs” and should take a
more serious effort. So, this PR doesn’t do that.
[Reviewed by @daviditen and @ronawho]
Test:
- [x] standard in types/string
- [x] linux32 in types/string
- [x] standard
- [x] gasnet
Modified Files:
A test/types/string/cast/intLimits.chpl
A test/types/string/cast/intLimits.good
A test/types/string/diten/stringToRealError.chpl
A test/types/string/diten/stringToRealError.good
M modules/internal/StringCasts.chpl
M runtime/src/chplcast.c
Compare: https://github.com/chapel-lang/chapel/compare/9f98dcd11fa6...e5c664ec700b