Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/export-wasm-references.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Install pinned WASI adapter
run: npm ci --ignore-scripts --prefix scripts/experimental
- name: Build the host compiler
run: make -C dev cppgm lowir2native CXX=g++ CPPGM_HOST_CXX=g++
run: make -C dev cppgm lowir2native lowiropt CXX=g++ CPPGM_HOST_CXX=g++
- name: Check the optional C assignment on Wasm
run: |
PATH="$RUNNER_TEMP/wasm-tools/bin:$PATH" \
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/intel-library-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,26 @@ jobs:
apt-get install -y --no-install-recommends bzip2 gdb ;;
wasm)
apt-get install -y --no-install-recommends curl xz-utils perl util-linux ;;
wasm-selfbuild)
apt-get install -y --no-install-recommends curl xz-utils perl nodejs npm ;;
index-cpp|simdjson|internal) ;;
*) exit 2 ;;
esac
git config --global --add safe.directory /work/source
git config --global --add safe.directory /work/tools
make -C dev cppgm -j16
jobs=16
if [ "$SUITE" = wasm-selfbuild ]; then jobs=2; fi
python3 -u ../tools/scripts/intel_library_benchmarks.py run \
--suite "$SUITE" --source /work/source --jobs 16
--suite "$SUITE" --source /work/source --jobs "$jobs"
'
- name: Report
if: always()
env:
SUITE: ${{ inputs.suite }}
run: |
report="source/obj/$SUITE/details.md"
if [ "$SUITE" = wasm-selfbuild ]; then report="source/obj/$SUITE/summary.md"; fi
if [ -f "$report" ]; then cat "$report" >> "$GITHUB_STEP_SUMMARY"; fi
- name: Collect results and diagnostics
if: always()
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ on:
description: Intel runner label supplied by the temporary-runner helper
type: string
default: cppgm-intel
intel_suite:
description: Dedicated Intel measurement to run
type: choice
options: [wasm, wasm-selfbuild]
default: wasm

permissions:
contents: read

concurrency:
group: wasm-benchmarks-${{ github.ref }}-${{ inputs.platform || 'github' }}
group: wasm-benchmarks-${{ github.ref }}-${{ inputs.platform || 'github' }}-${{ inputs.intel_suite || 'wasm' }}
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -258,6 +263,6 @@ jobs:
contents: write
uses: ./.github/workflows/intel-library-benchmarks.yml
with:
suite: wasm
suite: ${{ inputs.intel_suite || 'wasm' }}
revision: ${{ inputs.revision || github.sha }}
runner_label: ${{ inputs.runner_label }}
6 changes: 6 additions & 0 deletions TESTING_AND_REFERENCES.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ not grow. The source-only `pa34/maintainer/Makefile` retains census and Cachegri
targets, which are not student requirements; the course lane
`make -C pa34 test-kernels` (PA36's kernels under Cachegrind, at PA34's
limit) is one, so `make test-report` needs valgrind.
The PA33 and PA37 `maintainer/Makefile`s also turn on a check of this
solution's `cppgm -S -emit-lowir` (the LowIR that `-c` compiles, after the
LowIR optimizer). PA33's object round trip and PA37's Wasm checker compile
each object again from that text with `-c -fno-lowir-passes`, after
`lowiropt -O0` has read and written it, and compare it with the direct
object byte for byte.
Keep solution-specific expectations out of graded course fixtures.

## Reference policy
Expand Down
52 changes: 36 additions & 16 deletions dev/cppgm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ struct SourceOutputInvocation
// `--hosted`: the host environment -c uses (include paths, predefined
// macros, builtin declarations, hosted analysis), so a hosted source's
// views are those of the program -c compiles (--emit-lowir's LowIR view
// always preprocesses so; its object dialect is the object half's, see
// always preprocesses so; the object half's program is -c's, see
// run_emit_lowir_mode). `-I`, `-D` and `-U` as the driver takes them.
bool hosted = false;
bool nostdinc = false;
Expand Down Expand Up @@ -675,11 +675,17 @@ DriverInvocation parse_driver_invocation(const vector<string>& args)
{
throw InvocationError("query flag must be used as a direct invocation");
}
if (args[i] == "-c")
// -S (only with -emit-lowir, which the toolchain checks) compiles
// as -c does and writes the program as LowIR text.
if (args[i] == "-c" || args[i] == "-S")
{
compile_only = true;
continue;
}
if (args[i] == "-emit-lowir" || args[i] == "-fno-lowir-passes" || args[i] == "-flowir-passes")
{
continue;
}
if (args[i] == "--stats" || args[i] == "--stats-functions" || args[i].compare(0, 15, "--verify-passes") == 0)
{
continue;
Expand Down Expand Up @@ -1100,26 +1106,36 @@ void report_lowir_stats(const lower::LoweringCounters& counters, const lowir::Pr
// constructed program first (audit builds).
int run_emit_lowir_mode(vector<string> args)
{
const vector<string> given = args;
const bool stats = consume_stats_flag(args);
const bool validate = consume_flag(args, "--validate");
SourceOutputInvocation invocation = parse_source_output_invocation(args, true);
invocation.optimizer.has_gnu_sincos = target_model::has_gnu_sincos(invocation.target);
// The LowIR half of an object compile: a `.lowir` output (the
// toolchain's LowIR object input, `-c x.lowir`) with the object
// compile's debug-information level stated (-g0, -gline-tables-only)
// is the program `-c -o x.o` compiles, lowered in host-object mode, in
// the object dialect, so the object it gives is the direct compile's
// (PA33 object roundtrip). Otherwise the output is the course's LowIR
// view in the course dialect, --hosted or not (the help text: --hosted
// is the program `-c -o x.o` compiles: the driver's -S -emit-lowir
// writes it, so the object it gives is the direct compile's (PA33
// object roundtrip).
if (invocation.debug_level && ends_with(invocation.outfile, ".lowir"))
{
if (validate)
throw InvocationError("--validate checks the LowIR view, not an object compile's LowIR");
vector<string> compile = { "-S", "-emit-lowir" };
for (const string& arg : given)
if (arg != "--hosted")
compile.push_back(arg);
return driver::run_toolchain(compile, source_preprocessor_options());
}
// Otherwise the output is the course's LowIR view, --hosted or not
// (the help text: --hosted
// selects the host environment, which this view preprocesses in
// anyway), which the LowIR lanes compare, the course's lowir and
// lowiropt read and the supplied course back end runs (PA12 controls:
// `--emit-lowir -O0 -o x.lowir`), as `.obj` names the course's object.
// Both state the instruction facts the lowering proved (lowir.md
// "Instruction Facts"), which the object compile reads.
const bool object_half = invocation.debug_level && ends_with(invocation.outfile, ".lowir");
if (object_half)
invocation.hosted = true;
// Both are LowIR that lowir and lowiropt read, and state the
// instruction facts the lowering proved (lowir.md "Instruction Facts"),
// which the object compile reads.
PreprocessorOptions options = source_preprocessor_options(invocation);
// The LowIR view preprocesses in the host environment -c uses (PA33: a
// source the driver lanes compile includes host headers).
Expand All @@ -1133,15 +1149,13 @@ int run_emit_lowir_mode(vector<string> args)
const bool optimizing = invocation.optimizer.level > 0;
if (!validate && !optimizing)
lowering.set_definition_stream(&definitions);
lowering.set_object_mode(object_half);
lowering.set_host_objects(object_half);
lowering.set_macho_objects(invocation.target == native::Target::MacOS);
lowering.set_optimizing(object_half || invocation.optimizer.level >= 2);
lowering.set_optimizing(invocation.optimizer.level >= 2);
lowering.set_strict_aliasing(invocation.strict_aliasing);
lowering.set_popcnt(options.popcnt);
lowering.set_exceptions(options.modes.exceptions);
// The LowIR view carries the source's debug locations when debug
// information is asked for, including the object roundtrip's view.
// information is asked for.
lowering.set_debug_locations(invocation.debug_info);
lowering.set_debug_types(invocation.debug_types);
double front_ms = 0, lower_ms = 0;
Expand Down Expand Up @@ -1284,7 +1298,13 @@ int run_cppgm(const vector<string>& raw_args)

if (has_help_arg(raw_args))
{
cout << cppgm_help_text();
// The course's flags, then this compiler's (the header: a tool may
// list more).
cout << cppgm_help_text() << "\n"
<< "this compiler's flags:\n"
" -S -emit-lowir write the LowIR that -c compiles, after the LowIR optimizer\n"
" (default output: <input>.lowir)\n"
" -fno-lowir-passes compile without the LowIR optimizer; the back end runs at the -O level\n";
return EXIT_SUCCESS;
}

Expand Down
1 change: 0 additions & 1 deletion dev/lowir_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ CppgmLowir* cppgm_lowir_create(uint32_t version, uint32_t target)
module->program.target = target == CPPGM_TARGET_LINUX ? target_model::Target::Linux
: target_model::Target::MacOS;
module->program.explicit_target = true;
module->program.object_facts = true;
return module.release();
}
catch (const InternalError&)
Expand Down
4 changes: 2 additions & 2 deletions dev/src/backend/lowir_c_metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const char* parameter_problem(const CppgmParameter& input, uint32_t index, lowir
return "object_bytes metadata requires ptr";
if (!lowir::valid_aggregate_shape(t, shape(input.shape_element, input.shape_count)))
return "invalid aggregate parameter shape";
if (!lowir::text_holds_object_classes(t, input.classes))
if (!lowir::valid_object_classes(t, input.classes))
return "invalid classes metadata";
if (input.pass == ir_model::PPM_INDIRECT_RESULT && (index != 0 || !result.is_void()))
return "invalid indirect result parameter";
Expand All @@ -61,7 +61,7 @@ const char* boundary_problem(CppgmType result, const CppgmBoundary& input)
return "invalid boundary metadata";
if (!lowir::valid_aggregate_shape(type(result), shape(input.result_shape_element, input.result_shape_count)))
return "invalid aggregate result shape";
if (!lowir::text_holds_object_classes(type(result), input.result_classes))
if (!lowir::valid_object_classes(type(result), input.result_classes))
return "invalid result_classes metadata";
return nullptr;
}
Expand Down
2 changes: 2 additions & 0 deletions dev/src/backend/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ struct Options
bool wasm_atomics = true;
WasmLinkOptions wasm_link;
const opt::OptimizerOptions* optimizer = nullptr;
// -fno-lowir-passes: the back end takes the program as it is.
bool lowir_passes = true;
};

} // namespace backend
Loading
Loading