@@ -110,7 +110,8 @@ void usage(std::FILE* out) {
110110 " -z force compression\n "
111111 " -x force decompression\n "
112112 " -i <path> input file\n "
113- " -o <path> output file, required with -z and -x\n "
113+ " -o <path> output file; without it -z and -x run fully\n "
114+ " but write nothing\n "
114115 " -t f32|f64 element type of the raw array, float32 or\n "
115116 " float64 (default f32)\n "
116117 " -eb abs <value> absolute error bound\n "
@@ -447,9 +448,8 @@ int run_compress(const Options& o, bool write_output) {
447448 if (o.eb_mode .empty ()) {
448449 die_usage (" no error bound; pass -eb abs <value> or -eb rel <value>" );
449450 }
450- if (write_output && o.out_path .empty ()) {
451- die_usage (" -z needs an output path; pass -o <path>" );
452- }
451+ // -z without -o runs the full compression and report but writes nothing.
452+ const bool write_file = write_output && !o.out_path .empty ();
453453
454454 std::vector<T> h_in = read_values<T>(o.in_path );
455455 const uint64_t n_file = (uint64_t )h_in.size ();
@@ -529,7 +529,7 @@ int run_compress(const Options& o, bool write_output) {
529529 const bool ok = (nonfinite == 0 ) && (max_err <= 1.01 * (double )eb_abs);
530530
531531 uint64_t total_bytes = 0 ;
532- if (write_output ) {
532+ if (write_file ) {
533533 if (o.bare ) {
534534 write_all (o.out_path , h_cmp.data (), h_cmp.size ());
535535 total_bytes = (uint64_t )h_cmp.size ();
@@ -564,7 +564,7 @@ int run_compress(const Options& o, bool write_output) {
564564 o.eb_mode .c_str (), o.eb_value , (double )eb_abs);
565565 std::printf (" compressed = %zu bytes\n " , (size_t )r.cmp_size );
566566 std::printf (" CR = %.4f\n " , cr);
567- if (write_output ) {
567+ if (write_file ) {
568568 if (o.bare ) {
569569 std::printf (" output = %s (%llu bytes, bare bitstream)\n " ,
570570 o.out_path .c_str (), (unsigned long long )total_bytes);
@@ -663,7 +663,7 @@ int run_decompress_typed(const Options& o, const DecompressPlan& p) {
663663 cudaFree (d_out);
664664 cudaFree (d_cmp);
665665
666- write_all (o.out_path , h_out.data (), n * sizeof (T));
666+ if (!o. out_path . empty ()) write_all (o.out_path , h_out.data (), n * sizeof (T));
667667
668668 const size_t out_bytes = n * sizeof (T);
669669 const double cr = (double )n * (double )sizeof (T) / (double )p.payload_size ;
@@ -678,7 +678,8 @@ int run_decompress_typed(const Options& o, const DecompressPlan& p) {
678678 p.from_header ? " (from the file header)" : " " );
679679 std::printf (" compressed = %zu bytes\n " , p.payload_size );
680680 std::printf (" CR = %.4f\n " , cr);
681- std::printf (" output = %s (%zu bytes)\n " , o.out_path .c_str (), out_bytes);
681+ if (!o.out_path .empty ())
682+ std::printf (" output = %s (%zu bytes)\n " , o.out_path .c_str (), out_bytes);
682683 std::printf (" decompress = %.2f ms (%.2f GB/s)\n " , d_ms, gbps (out_bytes, d_ms));
683684
684685 if (o.csv ) {
@@ -692,8 +693,6 @@ int run_decompress_typed(const Options& o, const DecompressPlan& p) {
692693}
693694
694695int run_decompress (const Options& o) {
695- if (o.out_path .empty ()) die_usage (" -x needs an output path; pass -o <path>" );
696-
697696 std::vector<unsigned char > raw = read_all (o.in_path );
698697
699698 DecompressPlan p;
0 commit comments