Skip to content

Profiling ​

Compile with -DGTAP_ENABLE_PROFILING to collect task-execution intervals in either execution mode.

gtap_export_profile ​

Copies recorded profiling data to the host, computes summary statistics, and writes a result directory.

Signature ​

cpp
gtap_profile_export_result gtap_export_profile(
    const gtap_profile_export_options& options = {}
);

Parameters ​

ParameterTypeDescription
optionsconst gtap_profile_export_options&Output location, optional label, and overwrite policy. Uses defaults when omitted.

Return value ​

Returns a gtap_profile_export_result. Inspect its status before using any generated path.

Requirements ​

  • Compile with GTAP_ENABLE_PROFILING to record data.
  • Call gtap_synchronize() before exporting.
  • Export before gtap_reset() or gtap_finalize(), which clear or release the GTaP profiler buffers.

Example ​

cpp
gtap_profile_export_result result = gtap_export_profile({
    .output_directory = "./profile/fib_%i",
    .overwrite = false,
});

if (result.status != gtap_profile_export_status::success) {
    fprintf(stderr, "Profile export failed: %s\n",
            gtap_profile_export_status_string(result.status));
}

gtap_profile_export_options ​

cpp
struct gtap_profile_export_options {
    const char* output_directory = "./profile";
    const char* label = nullptr;
    bool overwrite = false;
};

Fields ​

FieldDefaultDescription
output_directory"./profile"Result directory. Parent directories are created when possible. One %i marker selects the first non-existing numbered directory.
labelnullptrOptional label written to profile.json
overwritefalseAllow the three generated output files to replace existing files

A non-null label must contain 1–128 characters. Only ASCII letters, digits, hyphen (-), underscore (_), and period (.) are accepted.

output_directory must be non-empty and fit within the 512-byte result path buffers. At most one %i marker is allowed.

gtap_profile_export_result ​

cpp
struct gtap_profile_export_result {
    gtap_profile_export_status status;
    size_t recorded_intervals;
    size_t dropped_intervals;
    char result_directory[512];
    char profile_path[512];
    char intervals_path[512];
    char aggregates_path[512];
};

Fields ​

FieldDescription
statusFinal export status
recorded_intervalsNumber of complete task-execution intervals written
dropped_intervalsNumber of intervals omitted because a CUDA warp or thread block's profile buffer was full
result_directoryResolved output directory
profile_pathPath to profile.json
intervals_pathPath to task_execution_intervals.csv
aggregates_pathPath to task_execution_aggregates.csv

Paths are meaningful only when the corresponding stage of export succeeded.

gtap_profile_export_status ​

cpp
enum class gtap_profile_export_status {
    success = 0,
    invalid_label,
    invalid_output_directory,
    path_too_long,
    already_exists,
    cuda_error,
    out_of_memory,
    io_error,
    no_data,
    profiling_disabled
};
ValueMeaning
successAll output files were written successfully
invalid_labellabel is empty, too long, or contains unsupported characters
invalid_output_directoryThe directory pattern is invalid or cannot be created/resolved
path_too_longA generated output-file path does not fit in its 512-byte buffer
already_existsAn output file exists and overwrite is false
cuda_errorCopying or preparing profile data failed in CUDA
out_of_memoryA required host allocation failed
io_errorOpening, writing, or closing an output file failed
no_dataNo complete task-execution interval was recorded
profiling_disabledThe program was compiled without GTAP_ENABLE_PROFILING

Use gtap_profile_export_status_string(status) to obtain a printable lowercase status name.

Generated files ​

FileContents
profile.jsonMode, launch geometry, interval counts, dropped counts, and statistical summaries
task_execution_intervals.csvPer-warp or per-block start and end times; thread mode also records the executed task count for each interval
task_execution_aggregates.csvPer-warp or per-block totals and recorded execution span

GTaP is a research prototype under active development.