Loading...
Searching...
No Matches
q3::cli Namespace Reference

Classes

struct  GPUEntryPointDescriptor
 
struct  LauncherTasks
 What the launcher said, and which variable said it. More...
 
struct  Options
 

Typedefs

using EnvironmentLookup = std::function< const char *(const char *)>
 Environment reader, so the detection can be tested without setenv.
 

Functions

std::string build_identity (const std::string &binary_name)
 
LauncherTasks detect_launcher_tasks ()
 The same, against the real environment.
 
LauncherTasks detect_launcher_tasks (const EnvironmentLookup &lookup)
 
std::string input_format_choices ()
 The --format values every registered input format accepts, as usage text: <yaml|qe|...>.
 
std::string input_format_descriptions ()
 What a usage line says an input path may name: every registered format, in order.
 
Options parse_options (int argc, char *argv[], const std::string &binary_name)
 
void print_footer ()
 
void print_header ()
 
void print_timestamped_banner (const std::string &label_prefix)
 
void print_usage (const std::string &binary_name)
 
void print_version (const std::string &binary_name)
 
InputData read_input (Options &options, const std::string &binary_name)
 
int run_gpu_entry_point (int argc, char *argv[], const GPUEntryPointDescriptor &descriptor)
 
void validate_gpu_blas (execution::gpu::blas::GPUBLAS &gpu_blas, const std::string &blas_library_name)
 
void validate_gpu_device_backend (execution::gpu::device::GPUDeviceBackend &device_backend)
 
void validate_gpu_eigensolver (execution::gpu::lapack::GPUEigensolver &gpu_eigensolver, const std::string &eigensolver_library_name)
 

Typedef Documentation

◆ EnvironmentLookup

using q3::cli::EnvironmentLookup = typedef std::function<const char*(const char*)>

Environment reader, so the detection can be tested without setenv.

Definition at line 36 of file launcher.hpp.

Function Documentation

◆ build_identity()

std::string q3::cli::build_identity ( const std::string &  binary_name)
inline

One line naming the build: version, and the commit if the build supplied one.

Assembled here rather than at each entry point so the five binaries cannot drift into reporting themselves differently. The commit is empty for a build from a dirty tree or from no repository at all – see version.hpp for why that is reported as unknown rather than guessed.

Definition at line 33 of file cli.hpp.

References q3::commit, and q3::version.

Referenced by print_version().

◆ detect_launcher_tasks() [1/2]

LauncherTasks q3::cli::detect_launcher_tasks ( )
inline

The same, against the real environment.

Definition at line 72 of file launcher.hpp.

References detect_launcher_tasks().

Referenced by detect_launcher_tasks(), and run_gpu_entry_point().

◆ detect_launcher_tasks() [2/2]

LauncherTasks q3::cli::detect_launcher_tasks ( const EnvironmentLookup &  lookup)
inline

Read the task count from lookup, taking the largest value any launcher variable reports and remembering which one it was – a message that names the variable can be checked by the reader, and a wrong guess can be argued with.

Definition at line 43 of file launcher.hpp.

References q3::cli::LauncherTasks::count, and q3::cli::LauncherTasks::variable.

◆ input_format_choices()

std::string q3::cli::input_format_choices ( )
inline

The --format values every registered input format accepts, as usage text: <yaml|qe|...>.

Definition at line 56 of file cli.hpp.

References q3::input_format_registry().

Referenced by print_usage().

◆ input_format_descriptions()

std::string q3::cli::input_format_descriptions ( )
inline

What a usage line says an input path may name: every registered format, in order.

Definition at line 61 of file cli.hpp.

References q3::input_format_registry().

Referenced by print_usage().

◆ parse_options()

Options q3::cli::parse_options ( int  argc,
char *  argv[],
const std::string &  binary_name 
)
inline

Parse command-line options shared by the q3, q3_mpi, and q3_gpu* binaries.

Recognized flags: –log-level <level>, –log-file <path>, –pools <n>, –distribute-bands, –precision <mode>, –format <name>, –material <file>, –check, –version. The input path is the first argument that is not a flag or a flag's value, so it may appear before or after the flags — q3 --format qe scf.in and q3 scf.in --format qe both work, and so does giving no path at all.

Leaving the path empty is not an error here. Only the entry point knows whether an argument-less invocation is meaningful: it is when a registered input format claims the working directory (resolve_argument_less_input()).

Parameters
argcArgument count from main().
argvArgument vector from main().
binary_nameNamed in the usage text, printed and followed by exit(1) only for a malformed flag.

Refused rather than ignored. Silently swallowing it made q3 --typo deck/ take "--typo" as the input path and discard the directory, which fails much further from the cause.

Definition at line 175 of file cli.hpp.

References q3::cli::Options::check_only, q3::cli::Options::distribute_bands, q3::log::error(), q3::cli::Options::format, q3::cli::Options::input_file, q3::cli::Options::log_file, q3::cli::Options::log_level, q3::cli::Options::material_file, q3::cli::Options::number_of_kpoint_pools, q3::cli::Options::number_of_kpoint_pools_was_set, q3::cli::Options::precision, print_usage(), and q3::cli::Options::print_version.

Referenced by main(), and run_gpu_entry_point().

◆ print_footer()

void q3::cli::print_footer ( )
inline

Definition at line 278 of file cli.hpp.

References print_timestamped_banner().

Referenced by main().

◆ print_header()

void q3::cli::print_header ( )
inline

Definition at line 274 of file cli.hpp.

References print_timestamped_banner().

Referenced by main().

◆ print_timestamped_banner()

void q3::cli::print_timestamped_banner ( const std::string &  label_prefix)
inline

Print an 80-column banner with a centered, timestamped label.

Definition at line 261 of file cli.hpp.

References q3::get_iso_timestamp_with_timezone(), and q3::log::info().

Referenced by main(), print_footer(), print_header(), and run_gpu_entry_point().

◆ print_usage()

void q3::cli::print_usage ( const std::string &  binary_name)
inline

The usage every binary prints: one text, so the binaries cannot drift apart. A flag a binary has no use for is read and ignored there, as documented in docs/io_reference.md.

Definition at line 140 of file cli.hpp.

References q3::log::error(), input_format_choices(), and input_format_descriptions().

Referenced by parse_options(), and read_input().

◆ print_version()

void q3::cli::print_version ( const std::string &  binary_name)
inline

Print what --version reports: the build identity on its own first line, which scripts parse, then the add-ons compiled in, when there are any.

Definition at line 45 of file cli.hpp.

References q3::active_addons(), build_identity(), and q3::log::info().

Referenced by main(), and run_gpu_entry_point().

◆ read_input()

InputData q3::cli::read_input ( Options &  options,
const std::string &  binary_name 
)
inline

Read the input every binary runs, the same way in each: resolve an omitted path (the working directory, when a registered input format claims it), parse it, substitute --material's structure, and apply the input's verbosity.

Throws, after printing the usage, when no input was given and none is found.

Definition at line 239 of file cli.hpp.

References q3::log::apply_verbosity(), q3::InputFormat::display_name(), q3::cli::Options::format, q3::format_claiming_directory(), q3::log::info(), q3::cli::Options::input_file, q3::cli::Options::log_level, q3::cli::Options::material_file, q3::parse_input(), print_usage(), q3::substitute_material(), and q3::InputData::verbosity.

Referenced by main(), and run_gpu_entry_point().

◆ run_gpu_entry_point()

int q3::cli::run_gpu_entry_point ( int  argc,
char *  argv[],
const GPUEntryPointDescriptor &  descriptor 
)
inline

Run the full GPU entry-point flow for the backend described by 'descriptor'. Returns the process exit code.

Answered before the input is resolved, so --version works in a directory holding no input.

One process, or none. There is no multi-process mode here: the GPU path builds a serial iterator, so every task of a multi-task step would set up the whole problem on its own device, converge it, and print the same answer – which is what srun -n 2 q3_gpu_cuda did until 2026-09-11, silently, for twice the allocation and 2% more wall time (camsai/q3#15).

Refused after –version so srun q3_gpu_cuda --version still answers, and before anything touches a device.

The one case where several tasks running the same binary is what the user meant: packing independent calculations into one step. Nothing here can tell that apart from the mistake, so it is opt-in.

Backends without a native GPU FFT run the FP64 path through the PlanewaveBasis FFTW grid (gpu_fft_grid stays null).

── Step 2: Every flavor's iterator: serial policy, GPU Davidson ───── Handed to the flavor rather than built here, so whichever flavor the input names – the SCF, or the non-self-consistent pass of a band structure or a DOS – diagonalizes on this device in this precision.

Definition at line 131 of file gpu_entry_point.hpp.

References q3::cli::GPUEntryPointDescriptor::backend_label, q3::cli::GPUEntryPointDescriptor::binary_name, q3::cli::GPUEntryPointDescriptor::blas_library_name, q3::cli::GPUEntryPointDescriptor::create_blas, q3::cli::GPUEntryPointDescriptor::create_eigensolver, q3::cli::GPUEntryPointDescriptor::create_fft_grid, q3::create_flavor(), q3::execution::gpu::device::create_gpu_device_backend(), q3::create_kohn_sham_iterator(), q3::PlanewaveDavidsonDiagonalizer::default_serial_execution_policy, detect_launcher_tasks(), q3::cli::GPUEntryPointDescriptor::eigensolver_library_name, q3::log::error(), q3::log::info(), q3::log::init(), q3::ProfilingCounters::instance(), q3::cli::GPUEntryPointDescriptor::mixed_precision_description, parse_options(), print_timestamped_banner(), print_version(), read_input(), q3::addons::register_all(), q3::log::set_level(), validate_gpu_blas(), validate_gpu_device_backend(), validate_gpu_eigensolver(), q3::log::warn(), q3::write_companion_outputs(), and q3::write_results_json().

Referenced by main().

◆ validate_gpu_blas()

void q3::cli::validate_gpu_blas ( execution::gpu::blas::GPUBLAS &  gpu_blas,
const std::string &  blas_library_name 
)
inline

Quick BLAS sanity: compute dot product of [1+0i, 0+1i] with itself Expected: conj([1,i]) · [1,i] = 1*1 + (-i)*i = 1 + 1 = 2

Definition at line 89 of file gpu_entry_point.hpp.

References q3::execution::gpu::blas::GPUBLAS::dot_product(), and q3::log::info().

Referenced by run_gpu_entry_point().

◆ validate_gpu_device_backend()

◆ validate_gpu_eigensolver()

void q3::cli::validate_gpu_eigensolver ( execution::gpu::lapack::GPUEigensolver &  gpu_eigensolver,
const std::string &  eigensolver_library_name 
)
inline