Repository navigation
driver: -j with --legacy-codegen checks in parallel, then the AST code generator makes the MLIR - #4006
Open
bajpainaman wants to merge 2 commits into
Open
driver: -j with --legacy-codegen checks in parallel, then the AST code generator makes the MLIR#4006bajpainaman wants to merge 2 commits into
bajpainaman wants to merge 2 commits into
Conversation
…e generator makes the MLIR `vxc -j N --legacy-codegen` stopped with "-j does not support --legacy-codegen yet". The parallel compile in execute_parallel gave its work only to the flat code generator. So a RUN line with -j could not run on the AST code generator, and the parity mode skipped those lines. Now -j with --legacy-codegen runs the parallel frontend. The new check_modules_for_ast_codegen in src/pipeline.rs then builds the modules in the form that the sequential driver gives to MeliorGenerator. It takes the generic instances in the order of the sequential checks, keeps the first copy of each by name and removes comptime functions. The MLIR is the same bytes as a normal --legacy-codegen compile. The checker names closures, tasks and vec! values with a counter, such as Closure_1. Each parallel check starts the counter again, so two functions would get the same name. A program that has one goes to the sequential driver, with a note on stderr. The parity mode no longer skips -j lines. Four -j fixtures checked text that only the flat code generator writes. Two now end with `# flat-codegen`, and two use -DAG checks. Fixes: vx-lang#3139 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iver The rule that sent a program to the sequential driver read every counter of the checker. A `?` on a Result also counts, so every program with `?` took the sequential path, and the note on stderr named the wrong reason. Only the names of closures reach the MLIR. The names that `?`, `vec!` and tasks get stay in one function. So the rule now looks only for a closure, which is the one thing that makes a struct. The fixture now compares the bytes at -j 1, -j 2 and -j 8 with a sequential compile, and has functions with `?` and `vec!` that must take the parallel path. Two old -j fixtures keep their exact checks of the flat code generator's order, with `# flat-codegen` instead of -DAG. Issue: vx-lang#3139 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hiraditya
reviewed
Dec 4, 2026
hiraditya
left a comment
Collaborator
There was a problem hiding this comment.
I read the code. Three points:
- The PR description says that the normal compile starts the counters of
?,vec!and tasks again in each function. It does not:TaskCx::enter_functionkeepsnext_id, andTypeChecker.next_idnever restarts. So the names$okNand_vec_macro_tmp_Ndiffer between a normal and a parallel compile. They do not reach the--emit-mlirtext, socmppasses. Please correct the description, and check that the debug information is also the same. - For an imported function with a type error that nothing uses, a normal compile keeps the generic instances that its check made. The parallel compile clears them (
c.monomorphs.clear()). That can give an extra function, or another order. I did not run it. - The branch is from d3ed6cf, and main changed the normal compile since then (#4136, #4163, #4485, #4531). Please merge main and run the byte comparison of the 1,472 files again.
Generated With Claude Code
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
vxc -j N --legacy-codegenstopped with "-j does not support --legacy-codegen yet".execute_parallelinsrc/driver.rsgave the work of the parallel frontend only to the flat code generator. So a RUN line with-jcould not run on the AST code generator, and the parity mode of #1831 skipped those lines.Now
-j N --legacy-codegenruns the parallel frontend. A new function,check_modules_for_ast_codegeninsrc/pipeline.rs, then builds the entry module and the imported modules in the form that the sequential driver gives toMeliorGenerator. It takes the generic instances in the order of the sequential checks: the entry module's functions, methods and transfer lowerings, then the lowerings and the free functions of the imported modules. Each parallel check makes its own copy of an instance, so it keeps the first one by name, as the sequential checker makes it once. Comptime functions are removed as the sequential driver removes them. The output is the same bytes as a normal--legacy-codegencompile.One decision for review: the checker names a closure with a counter (
Closure_1), and that name is in the MLIR. A sequential check keeps one counter for the whole program. A parallel check starts it again in each function, so two functions would both makeClosure_1. Renaming them would need a change in the checker. Instead, a program with a closure goes to the sequential driver, with a note on stderr. The names that?,vec!and tasks get from counters stay in one function, and the sequential driver also starts them again in each function. So those programs take the parallel path. #4012 asks to number closures per program in a parallel check. This is the same thing-jdoes when the flat emitter does not take a program. Without that rule, the second closure in the new closure fixture runs the body of the first one, and the program prints12instead of6.The parity mode in
compile_test.rsno longer skips-jlines. Four old-jfixtures check text that only the flat code generator writes, such as the order of its functions. Their RUN lines now end with# flat-codegen, so the normal run keeps its exact checks and the parity mode runs them unchanged.jobs_refuses_a_flag_it_cannot_honour.vxnow checks--verify-seams, which-jstill refuses.Tested:
vxc -j 2 --legacy-codegen --emit-mlirprinted "-j does not support --legacy-codegen yet" with exit 1. After: it compiles.vxc --legacy-codegen --emit-mlirwithvxc -j 2 --legacy-codegen --emit-mliron every file intests/backend/pass,tests/frontend/passandtests/optimizations/pass(1,472 files):--legacy-codegen(they need flags such as--machine, or a GPU).-jpath on main too, with the same errors (E3063 with?on std Results -j: ? on a Result of std::net gets E3063 although the function returns Result<_, NetError> #3834, E3003, E3033, E3036, E8006). This PR does not change the checks.gpu_that_shares_host_memory_gets_host_tensors.vx,spirv_region_with_a_lane_routine_gets_an_image.vx,a_spirv64_kernel_with_an_nvvm_op_gets_no_image.vx,built_in_gpu_topology_reaches_smem.vxandgpu_kernels_written_as_ptx.vx. Each one gives two different outputs in 8 runs of plain--legacy-codegen, without-j. The cause is a walk of aHashMapinlower_spawn_region, and this PR does not cause it.-j 1,-j 2and-j 8with the sequential output, and has functions with?andvec!that must take the parallel path.-jfixtures and the 2 new ones, ascompile_test.rsruns them, withVX_NO_AST_FALLBACK=1. All 63 pass, and all 63 pass again in the parity mode.--legacy-codegen: thesame bytesCHECK failed, and the closure fixture's note CHECK failed. Instances sorted by name:same bytes. No first-by-name dedup: the-j 2compile failed. No closure rule: the closure fixture's note CHECK failed, and its program printed12instead of6. Comptime functions kept:same bytes. Checks in their parallel order:same bytes. Every program sent to the sequential driver: thePATHCHECK. A wrong order only at-j 1:same bytes at -j 1. A wrong order only at 8 threads:same bytes at -j 8.cargo fmt --all.cargo clippy --workspace --all-targets -- -D warningson Rust 1.100 stops at 10 errors from main's ownspan: _, ..patterns, which clippy: remove wildcard fields that a..in the same pattern matches #3977 fixes. With only that lint allowed (-A clippy::unneeded_wildcard_pattern), clippy passes on every target.I did not run the full
cargo testsuite, the CI parity workflow, or macOS or GPU fixtures.Fixes #3139.