You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are currently missing support for many Fortran intrinsics. We want to start with map-style Fortran intrinsics and math functions - these have already been added to Fortran AST components, but we need to verify they are correctly handled when translating AST and generating SDFG.
Map Style Intrinsics
Currently, the Fortran frontend supports the SUM intrinsic, translated to a (nested) loop summing variables in an array. However, it does not seem to work entirely correctly. For example, this code is valid in Fortran but fails in DaCe - we fail to preallocate loop iterator variables when the SUM is the first node:
PROGRAM ranges_test
implicit nonedouble precision d(3,4,5)
d(:,:,:) =42CALL array_ranges_test_function(d)
end
SUBROUTINEarray_ranges_test_function(d)
double precision d(3,4,5),e(3,4,5)
d(1,1,1)=SUM(e(:,1,:))
ENDSUBROUTINE array_ranges_test_function
Error:
Traceback (most recent call last):
File "/work/dace/2023/fortran/dace/tests/fortran/intrinsincs_map.py", line 90, in <module>
test_fortran_frontend_intrinsic()
File "/work/dace/2023/fortran/dace/tests/fortran/intrinsincs_map.py", line 76, in test_fortran_frontend_intrinsic
sdfg = fortran_parser.create_sdfg_from_string(test_string, "sum_intrinsinc_test")
File "/work/dace/2023/fortran/dace/dace/frontend/fortran/fortran_parser.py", line 1087, in create_sdfg_from_string
ast2sdfg.translate(program, sdfg)
File "/work/dace/2023/fortran/dace/dace/frontend/fortran/fortran_parser.py", line 131, in translate
self.ast_elements[node.__class__](node, sdfg)
File "/work/dace/2023/fortran/dace/dace/frontend/fortran/fortran_parser.py", line 168, in ast2sdfg
self.translate(node.main_program.execution_part.execution, sdfg)
File "/work/dace/2023/fortran/dace/dace/frontend/fortran/fortran_parser.py", line 134, in translate
self.translate(i, sdfg)
File "/work/dace/2023/fortran/dace/dace/frontend/fortran/fortran_parser.py", line 131, in translate
self.ast_elements[node.__class__](node, sdfg)
File "/work/dace/2023/fortran/dace/dace/frontend/fortran/fortran_parser.py", line 861, in call2sdfg
self.subroutine2sdfg(i, sdfg)
File "/work/dace/2023/fortran/dace/dace/frontend/fortran/fortran_parser.py", line 768, in subroutine2sdfg
self.translate(node.execution_part, new_sdfg)
File "/work/dace/2023/fortran/dace/dace/frontend/fortran/fortran_parser.py", line 131, in translate
self.ast_elements[node.__class__](node, sdfg)
File "/work/dace/2023/fortran/dace/dace/frontend/fortran/fortran_parser.py", line 178, in basicblock2sdfg
self.translate(i, sdfg)
File "/work/dace/2023/fortran/dace/dace/frontend/fortran/fortran_parser.py", line 131, in translate
self.ast_elements[node.__class__](node, sdfg)
File "/work/dace/2023/fortran/dace/dace/frontend/fortran/fortran_parser.py", line 283, in forstmt2sdfg
raise ValueError("Unknown variable " + decl_node.lval.name)
ValueError: Unknown variable tmp_parfor_0
Another type of intrinsics we want to support are math functions. Currently, we support SQRT, COSH, ABS, EXP, and TANH. To support this, we must ensure that the function we translate to is supported in DaCe.
I’ve been getting into the DaCe project, I would like to start by helping support fortran math intrinsics to get my feet wet.
I've added some mapping entries for LOG in FortranIntrinsics.replace_function_name and FortranIntrinsics.replace_function_reference, but I’ve hit a bit of a roadblock – my test for LOG isn't passing, and I suspect there's something missing in my approach.
To give you a better idea of where I’m at, I've opened a PR [https://github.com//pull/1545]. It's still a work in progress, but I thought it might help to show exactly where I'm stuck. Any hints, tips, or guidance you can offer would be awesome and really appreciated. Just looking for a nudge in the right direction. Thanks a lot for taking the time to check this out. Excited to hear your thoughts and hoping to make this feature work with your help!
@yx-xyc Thanks for your interest! In fact, we made a lot of progress on this issue in branch multi_sdfg.
Furthermore, this is a very specific problem related to one part of DaCe's frontend. I'd recommend to look at other more general issues, which will give you better exposure to DaCe and help to understand SDFGs better :)
We are currently missing support for many Fortran intrinsics. We want to start with map-style Fortran intrinsics and math functions - these have already been added to Fortran AST components, but we need to verify they are correctly handled when translating AST and generating SDFG.
Map Style Intrinsics
Currently, the Fortran frontend supports the
SUM
intrinsic, translated to a (nested) loop summing variables in an array. However, it does not seem to work entirely correctly. For example, this code is valid in Fortran but fails in DaCe - we fail to preallocate loop iterator variables when theSUM
is the first node:Error:
This are handled in PRs #1390 and #1394
Math Style Intrinsics
Another type of intrinsics we want to support are math functions. Currently, we support
SQRT
,COSH
,ABS
,EXP
, andTANH
. To support this, we must ensure that the function we translate to is supported in DaCe.Math intrinsics we need to cover:
ACOS
ATAN2
ASIN
SINH
LOG
CC: @acalotoiu
The text was updated successfully, but these errors were encountered: