Run test for all configurations
(self, configurations, output_csv=None)
| 173 | return best |
| 174 | |
| 175 | def run_tuning(self, configurations, output_csv=None): |
| 176 | """Run test for all configurations""" |
| 177 | print(f"\n🚀 Starting tuning process with {len(configurations)} configurations") |
| 178 | print(f"📊 Model: {self.model_path}") |
| 179 | print(f"🧵 Threads: {self.threads}\n") |
| 180 | |
| 181 | # Backup configuration |
| 182 | self.backup_config() |
| 183 | |
| 184 | try: |
| 185 | # Test all configurations |
| 186 | for i, config in enumerate(configurations, 1): |
| 187 | print(f"\n[{i}/{len(configurations)}]") |
| 188 | self.test_configuration(**config) |
| 189 | |
| 190 | # Save results |
| 191 | if output_csv is None: |
| 192 | timestamp = datetime.now().strftime('%Y%m%d_%H%M%S') |
| 193 | csv_path = f"../stats/tuning_results_{timestamp}.csv" |
| 194 | else: |
| 195 | csv_path = output_csv |
| 196 | |
| 197 | # Ensure stats directory exists |
| 198 | os.makedirs(os.path.dirname(csv_path), exist_ok=True) |
| 199 | self.save_results(csv_path) |
| 200 | |
| 201 | # Find best configuration |
| 202 | best = self.find_best_config() |
| 203 | if best: |
| 204 | print(f"\n{'='*80}") |
| 205 | print(f"🏆 BEST CONFIGURATION FOUND!") |
| 206 | print(f"{'='*80}") |
| 207 | print(f"Configuration: {best['config_name']}") |
| 208 | print(f"ACT_PARALLEL: {best['act_parallel']}") |
| 209 | print(f"ROW_BLOCK_SIZE: {best['row_block_size']}") |
| 210 | print(f"COL_BLOCK_SIZE: {best['col_block_size']}") |
| 211 | print(f"PARALLEL_SIZE: {best['parallel_size']}") |
| 212 | print(f"PP128 Throughput: {best['pp_throughput']:.2f} ± {best['pp_std_dev']:.2f} t/s") |
| 213 | print(f"{'='*80}\n") |
| 214 | |
| 215 | # Show the configuration that will be written |
| 216 | print("Configuration to be written to gemm-config.h:") |
| 217 | print("-" * 80) |
| 218 | if best['act_parallel']: |
| 219 | print("#define ACT_PARALLEL") |
| 220 | print(f"#define ROW_BLOCK_SIZE {best['row_block_size']}") |
| 221 | print(f"#define COL_BLOCK_SIZE {best['col_block_size']}") |
| 222 | print(f"#define PARALLEL_SIZE {best['parallel_size']}") |
| 223 | print("-" * 80) |
| 224 | |
| 225 | # Apply best configuration |
| 226 | apply = input("\nDo you want to apply this configuration to gemm-config.h? (y/n): ").strip().lower() |
| 227 | if apply == 'y': |
| 228 | self.generate_config( |
| 229 | best['act_parallel'], |
| 230 | best['row_block_size'], |
| 231 | best['col_block_size'], |
| 232 | best['parallel_size'] |
no test coverage detected