Skip to content

Commit

Permalink
Add setting Codegen NG flag during fuzzer sample generation.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 702185844
  • Loading branch information
hongted authored and copybara-github committed Dec 3, 2024
1 parent a16c353 commit 4d46c68
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
38 changes: 20 additions & 18 deletions xls/codegen/convert_ir_to_blocks_passes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,20 @@ absl::StatusOr<bool> ConvertFuncsToPipelinedBlocksPass::RunInternal(
CodegenPassResults* results) const {
bool changed = false;

if (options.codegen_options.manual_control().has_value()) {
return absl::UnimplementedError("Manual pipeline control not implemented");
}
if (options.codegen_options.split_outputs()) {
return absl::UnimplementedError("Splitting outputs not supported.");
}
if (options.codegen_options.reset().has_value() &&
options.codegen_options.reset()->reset_data_path()) {
return absl::UnimplementedError("Data path reset not supported");
}

for (auto& [fb, block] : unit->function_base_to_block_) {
if (fb->IsFunction()) {
if (options.codegen_options.manual_control().has_value()) {
return absl::UnimplementedError(
"Manual pipeline control not implemented");
}
if (options.codegen_options.split_outputs()) {
return absl::UnimplementedError("Splitting outputs not supported.");
}
if (options.codegen_options.reset().has_value() &&
options.codegen_options.reset()->reset_data_path()) {
return absl::UnimplementedError("Data path reset not supported");
}

Function* f = fb->AsFunctionOrDie();

VLOG(3) << "Converting function to a pipelined block:";
Expand All @@ -244,15 +245,16 @@ absl::StatusOr<bool> ConvertProcsToPipelinedBlocksPass::RunInternal(
CodegenPassResults* results) const {
bool changed = false;

if (options.codegen_options.manual_control().has_value()) {
return absl::UnimplementedError("Manual pipeline control not implemented");
}
if (options.codegen_options.split_outputs()) {
return absl::UnimplementedError("Splitting outputs not supported.");
}

for (auto& [fb, block] : unit->function_base_to_block_) {
if (fb->IsProc()) {
if (options.codegen_options.manual_control().has_value()) {
return absl::UnimplementedError(
"Manual pipeline control not implemented");
}
if (options.codegen_options.split_outputs()) {
return absl::UnimplementedError("Splitting outputs not supported.");
}

Proc* proc = fb->AsProcOrDie();

VLOG(3) << "Converting proc to a pipelined block:";
Expand Down
1 change: 1 addition & 0 deletions xls/fuzzer/sample.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ bool SampleOptions::operator==(const SampleOptions& other) const {
proto.set_optimize_ir(true);
proto.set_use_jit(true);
proto.set_codegen(false);
proto.set_codegen_ng(false);
proto.set_simulate(false);
proto.set_use_system_verilog(true);
proto.set_calls_per_sample(1);
Expand Down
6 changes: 6 additions & 0 deletions xls/fuzzer/sample_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,12 @@ absl::StatusOr<Sample> GenerateSample(
generator_options.generate_proc &&
!generator_options.emit_stateless_proc,
min_stages, has_nb_recv, bit_gen));

// Randomly also turn on Codegen NG pipeline.
bool use_codegen_ng = absl::Bernoulli(bit_gen, 0.5);
if (use_codegen_ng) {
sample_options_copy.set_codegen_ng(true);
}
}

// Parse and type check the DSLX input to retrieve the top entity. The top
Expand Down

0 comments on commit 4d46c68

Please sign in to comment.