-
Notifications
You must be signed in to change notification settings - Fork 128
Tuo debug #1103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Tuo debug #1103
Changes from all commits
d5134fa
6db992d
e235612
50a572d
0c827ab
4dfff2e
aca57a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -678,7 +678,7 @@ contains | |||||||||
| do i = 1, boundary_edge_count | ||||||||||
| boundary_edge(1) = boundary_v(i, 2, 1) - boundary_v(i, 1, 1) | ||||||||||
| boundary_edge(2) = boundary_v(i, 2, 2) - boundary_v(i, 1, 2) | ||||||||||
| edgetan = boundary_edge(1)/boundary_edge(2) | ||||||||||
| edgetan = boundary_edge(1)/max(sgm_eps, boundary_edge(2)) | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Sign-preservation bug: using Severity Level: Minor
Suggested change
Why it matters? ⭐This is the correct approach: clamp the magnitude to avoid tiny denominators but restore the original sign so the tangent keeps the correct orientation. The sign(...) wrapper yields a denominator with the clamped magnitude and the original sign, so downstream checks that rely on edgetan's sign remain valid. This directly addresses the visible logic bug in the PR diff. Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** src/common/m_model.fpp
**Line:** 681:681
**Comment:**
*Logic Error: Sign-preservation bug: using `max(sgm_eps, abs(...))` fixes magnitude but loses the original sign of `boundary_edge(2)` when `sgm_eps` is chosen; compute the denominator with the magnitude but preserve the original sign so the computed tangent keeps the correct orientation.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Division protection breaks for negative values. When Prompt for AI agents
Suggested change
|
||||||||||
|
|
||||||||||
| if (abs(boundary_edge(2)) < threshold_vector_zero) then | ||||||||||
| if (edgetan > 0._wp) then | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1377,8 +1377,7 @@ contains | |||||||||||||||
|
|
||||||||||||||||
| #ifndef MFC_PRE_PROCESS | ||||||||||||||||
| subroutine s_compute_speed_of_sound(pres, rho, gamma, pi_inf, H, adv, vel_sum, c_c, c, qv) | ||||||||||||||||
| $:GPU_ROUTINE(function_name='s_compute_speed_of_sound', & | ||||||||||||||||
| & parallelism='[seq]', cray_inline=True) | ||||||||||||||||
| $:GPU_ROUTINE(parallelism='[seq]') | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The GPU annotation lacks an explicit Severity Level: Critical 🚨
Suggested change
Why it matters? ⭐Other routines in this file (e.g. s_compute_pressure, s_compute_fast_magnetosonic_speed, Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** src/common/m_variables_conversion.fpp
**Line:** 1380:1380
**Comment:**
*Possible Bug: The GPU annotation lacks an explicit `function_name` argument; other routines in this file provide `function_name` so the GPU toolchain may rely on it for symbol mapping—without it the offload/annotation processor may not correctly associate the pragma with this subroutine and the annotation may be ignored or misapplied. Add the function_name to match the pattern used elsewhere.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. |
||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
1379
to
1381
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Search for GPU_ROUTINE macro definition
fd -e fpp -e f90 | xargs grep -l "define.*GPU_ROUTINE" || true
rg "GPU_ROUTINE" --type f90 --type fpp -B 2 -A 5 | head -100Repository: MFlowCode/MFC Length of output: 84 🏁 Script executed: # Look for macro definitions in includes or preprocessor files
fd "macros" --type f
fd -e fpp | xargs grep -l "GPU_ROUTINE"Repository: MFlowCode/MFC Length of output: 951 🏁 Script executed: # Check for fypp macro definitions
fd -e fpp -path "*/macros*"
rg "\#:def.*GPU_ROUTINE" --type fpp || rg "GPU_ROUTINE" --type fpp | head -50Repository: MFlowCode/MFC Length of output: 281 🏁 Script executed: # Read the main macros file to find GPU_ROUTINE definition
cat src/common/include/macros.fpp | head -200Repository: MFlowCode/MFC Length of output: 6174 🏁 Script executed: # Search for GPU_ROUTINE in all .fpp files
grep -r "GPU_ROUTINE" src/common/include/ src/simulation/ src/common/ --include="*.fpp" | head -50Repository: MFlowCode/MFC Length of output: 4576 🏁 Script executed: # Look for the specific macro definition
grep -n "GPU_ROUTINE" src/common/include/macros.fpp src/common/include/parallel_macros.fpp src/common/include/acc_macros.fpp 2>/dev/null | head -30Repository: MFlowCode/MFC Length of output: 225 🏁 Script executed: # Read the GPU_ROUTINE macro definition
sed -n '51,150p' src/common/include/parallel_macros.fppRepository: MFlowCode/MFC Length of output: 4689 Include The Suggested change- $:GPU_ROUTINE(parallelism='[seq]')
+ $:GPU_ROUTINE(function_name='s_compute_speed_of_sound', parallelism='[seq]')📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| real(wp), intent(in) :: pres | ||||||||||||||||
| real(wp), intent(in) :: rho, gamma, pi_inf, qv | ||||||||||||||||
|
|
||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1233,7 +1233,7 @@ contains | |||||
| q_cons_vf(mom_idx%beg)%sf(j - 2, k, l), G_local) | ||||||
| else | ||||||
| call s_compute_pressure( & | ||||||
| q_cons_vf(1)%sf(j - 2, k, l), & | ||||||
| q_cons_vf(E_idx)%sf(j - 2, k, l), & | ||||||
| q_cons_vf(alf_idx)%sf(j - 2, k, l), & | ||||||
| dyn_p, pi_inf, gamma, rho, qv, rhoYks(:), pres, T) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Passing Severity Level: Critical 🚨
Suggested change
Why it matters? ⭐Passing an explicit section ( Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** src/simulation/m_data_output.fpp
**Line:** 1238:1238
**Comment:**
*Possible Bug: Passing `rhoYks(:)` creates an explicit array section expression; in some compilers this can create a temporary and change argument association semantics. Use the array name `rhoYks` (no `(:)`) to pass the array directly and avoid inadvertent temporaries or subtle differences in argument passing.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. |
||||||
| end if | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -46,6 +46,8 @@ module m_time_steppers | |||||
|
|
||||||
| use m_body_forces | ||||||
|
|
||||||
| use m_derived_variables | ||||||
|
|
||||||
| implicit none | ||||||
|
|
||||||
| type(vector_field), allocatable, dimension(:) :: q_cons_ts !< | ||||||
|
|
@@ -533,6 +535,7 @@ contains | |||||
|
|
||||||
| if (probe_wrt) then | ||||||
| call s_time_step_cycling(t_step) | ||||||
| call s_compute_derived_variables(t_step, q_cons_ts(1)%vf, q_prim_ts1, q_prim_ts2) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Missing GPU -> host synchronization before calling a host-side routine: Severity Level: Minor
Suggested change
Why it matters? ⭐The call to s_compute_derived_variables occurs after GPU kernels update q_cons_ts(1)%vf / related probe arrays. Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** src/simulation/m_time_steppers.fpp
**Line:** 538:538
**Comment:**
*Race Condition: Missing GPU -> host synchronization before calling a host-side routine: `s_compute_derived_variables` reads arrays that may currently reside/been updated on the device (GPU) but were not updated back to the host, causing stale or invalid data to be used on the host and incorrect results or crashes. Insert a GPU update to ensure the host view of `q_cons_ts(1)%vf`, `q_prim_ts1`, and `q_prim_ts2` is current before the call.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. |
||||||
| end if | ||||||
|
|
||||||
| if (cfl_dt) then | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,61 @@ | ||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||
|
|
||||||||||||||||||
| <%namespace name="helpers" file="helpers.mako"/> | ||||||||||||||||||
|
|
||||||||||||||||||
| % if engine == 'batch': | ||||||||||||||||||
| # flux: -N ${nodes} | ||||||||||||||||||
| # flux: -n ${tasks_per_node*nodes} | ||||||||||||||||||
| # flux: --job-name="${name}" | ||||||||||||||||||
| # flux: --output="${name}.out" | ||||||||||||||||||
| # flux: --error="${name}.err" | ||||||||||||||||||
| # flux: --time=${walltime} | ||||||||||||||||||
| # flux: --exclusive | ||||||||||||||||||
| # flux:--setattr=thp=always | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Logic/behaviour issue: the Flux directive comment is missing a space after the colon ( Severity Level: Minor
Suggested change
Why it matters? ⭐All other flux directives in the file use a space after "flux:". Many schedulers parse directives only when formatted consistently; adding the space makes the directive match the pattern used elsewhere and avoids it being ignored. Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** toolchain/templates/tuo.mako
**Line:** 13:13
**Comment:**
*Logic Error: Logic/behaviour issue: the Flux directive comment is missing a space after the colon (`# flux:--setattr=...`), which will likely prevent Flux from recognizing the directive; add the missing space so the scheduler parses the directive.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
|
||||||||||||||||||
| # flux:--setattr=thp=always | |
| # flux: --setattr=thp=always |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space in Flux directive will cause parsing failure.
The directive # flux:--setattr is missing a space after the colon, inconsistent with all other flux directives in this file.
Proposed fix
-# flux:--setattr=thp=always
+# flux: --setattr=thp=always📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # flux:--setattr=thp=always | |
| # flux: --setattr=thp=always |
🤖 Prompt for AI Agents
In @toolchain/templates/tuo.mako at line 13, The Flux directive line contains "#
flux:--setattr=thp=always" with a missing space after the colon which breaks
parsing; update that directive to include a space after the colon so it reads "#
flux: --setattr=thp=always" (preserving the flag and value) to match the other
flux directives in the template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Missing space after flux: - inconsistent with all other flux directives in this file. This typo may cause the flux scheduler to not recognize this directive.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At toolchain/templates/tuo.mako, line 13:
<comment>Missing space after `flux:` - inconsistent with all other flux directives in this file. This typo may cause the flux scheduler to not recognize this directive.</comment>
<file context>
@@ -0,0 +1,61 @@
+# flux: --error="${name}.err"
+# flux: --time=${walltime}
+# flux: --exclusive
+# flux:--setattr=thp=always
+# flux: --coral2-hugepages=512GB
+% if account:
</file context>
| # flux:--setattr=thp=always | |
| # flux: --setattr=thp=always |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Runtime error: ok is not a standard shell builtin/command and will cause "command not found" when the generated script runs; replace it with a portable print command (use printf or echo) so the message is actually emitted. [possible bug]
Severity Level: Critical 🚨
| ok ":) Loading modules:\n" | |
| printf "%s\n" ":) Loading modules:" |
Why it matters? ⭐
The template emits a shell script. "ok" is not a standard shell builtin/command and will cause "command not found" when the script runs. Replacing it with a portable print (printf or echo) fixes a real runtime error.
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** toolchain/templates/tuo.mako
**Line:** 25:25
**Comment:**
*Possible Bug: Runtime error: `ok` is not a standard shell builtin/command and will cause "command not found" when the generated script runs; replace it with a portable print command (use `printf` or `echo`) so the message is actually emitted.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Module load command uses wrong computer identifier.
The command uses -c t but the module slug defined in toolchain/modules is tuo, not t. This will cause the module loading to fail with "Computer not recognized" error.
Proposed fix
-. ./mfc.sh load -c t -m ${'g' if gpu else 'c'}
+. ./mfc.sh load -c tuo -m ${'g' if gpu else 'c'}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| . ./mfc.sh load -c t -m ${'g' if gpu else 'c'} | |
| . ./mfc.sh load -c tuo -m ${'g' if gpu else 'c'} |
🤖 Prompt for AI Agents
In @toolchain/templates/tuo.mako at line 28, The module load command is using
the wrong computer identifier ("-c t") which doesn't match the module slug
"tuo"; update the command in the template (the line invoking "./mfc.sh load -c t
-m ${'g' if gpu else 'c'}") to use "-c tuo" so it passes the correct computer
slug when invoking mfc.sh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Preserve the sign of
boundary_edge(2)when preventing division by zero to avoid an incorrect sign flip in theedgetancalculation. [possible issue, importance: 9]