From dfd332524ab0e66a04d803bb075787e35cd2db1a Mon Sep 17 00:00:00 2001 From: mcian Date: Mon, 21 Aug 2017 14:09:11 +0200 Subject: Remove multistrategy and related functions --- src/tuning/kernels/copy_fast.cpp | 7 ++--- src/tuning/kernels/copy_pad.cpp | 7 ++--- src/tuning/kernels/transpose_fast.cpp | 7 ++--- src/tuning/kernels/transpose_pad.cpp | 7 ++--- src/tuning/kernels/xaxpy.cpp | 7 ++--- src/tuning/kernels/xdot.cpp | 7 ++--- src/tuning/kernels/xgemm.cpp | 55 +++++------------------------------ src/tuning/kernels/xgemm_direct.cpp | 48 +++--------------------------- src/tuning/kernels/xgemv.cpp | 7 ++--- src/tuning/kernels/xger.cpp | 7 ++--- src/tuning/tuning.hpp | 3 +- src/utilities/utilities.hpp | 2 -- 12 files changed, 36 insertions(+), 128 deletions(-) (limited to 'src') diff --git a/src/tuning/kernels/copy_fast.cpp b/src/tuning/kernels/copy_fast.cpp index 5d70c219..c9bf478c 100644 --- a/src/tuning/kernels/copy_fast.cpp +++ b/src/tuning/kernels/copy_fast.cpp @@ -49,12 +49,11 @@ class TuneCopy { static size_t DefaultBatchCount() { return 1; } // N/A for this kernel static double DefaultFraction() { return 1.0; } // N/A for this kernel static size_t DefaultNumRuns() { return 10; } // run every kernel this many times for averaging - static size_t DefaultNumSearchStragegy() { return 1; } // N/A for this kernel static size_t DefaultSwarmSizePSO() { return 8; } // N/A for this kernel static double DefaultInfluenceGlobalPSO(){ return 0.1; }// N/A for this kernel static double DefaultInfluenceLocalPSO(){ return 0.3; }// N/A for this kernel static double DefaultInfluenceRandomPSO(){ return 0.6; }// N/A for this kernel - static size_t DefaultHeuristic(){ return size_t{0};} // Full Search + static size_t DefaultHeuristic(){ return static_cast (cltune::SearchMethod::FullSearch);} static double DefaultMaxTempAnn(){ return 1.0;}// N/A for this kernel // Describes how to obtain the sizes of the buffers @@ -108,8 +107,8 @@ class TuneCopy { static std::string PerformanceUnit() { return "GB/s"; } // Returns which Heuristic to run - static size_t GetCurrentHeuristic(const Arguments &args){ - return size_t{0}; // Full search + static size_t GetHeuristic(const Arguments &args){ + return static_cast (cltune::SearchMethod::FullSearch); } }; diff --git a/src/tuning/kernels/copy_pad.cpp b/src/tuning/kernels/copy_pad.cpp index c487aaf5..23f52d75 100644 --- a/src/tuning/kernels/copy_pad.cpp +++ b/src/tuning/kernels/copy_pad.cpp @@ -49,12 +49,11 @@ class TunePad { static size_t DefaultBatchCount() { return 1; } // N/A for this kernel static double DefaultFraction() { return 1.0; } // N/A for this kernel static size_t DefaultNumRuns() { return 10; } // run every kernel this many times for averaging - static size_t DefaultNumSearchStragegy() { return 1; } // N/A for this kernel static size_t DefaultSwarmSizePSO() { return 8; } // N/A for this kernel static double DefaultInfluenceGlobalPSO(){ return 0.1; }// N/A for this kernel static double DefaultInfluenceLocalPSO(){ return 0.3; }// N/A for this kernel static double DefaultInfluenceRandomPSO(){ return 0.6; }// N/A for this kernel - static size_t DefaultHeuristic(){ return size_t{0};} // Full Search + static size_t DefaultHeuristic(){ return static_cast (cltune::SearchMethod::FullSearch);} static double DefaultMaxTempAnn(){ return 1.0;}// N/A for this kernel // Describes how to obtain the sizes of the buffers @@ -116,8 +115,8 @@ class TunePad { static std::string PerformanceUnit() { return "GB/s"; } // Returns which Heuristic to run - static size_t GetCurrentHeuristic(const Arguments &args){ - return size_t{0}; // Full Search + static size_t GetHeuristic(const Arguments &args){ + return static_cast (cltune::SearchMethod::FullSearch); } }; diff --git a/src/tuning/kernels/transpose_fast.cpp b/src/tuning/kernels/transpose_fast.cpp index e169c831..308663d8 100644 --- a/src/tuning/kernels/transpose_fast.cpp +++ b/src/tuning/kernels/transpose_fast.cpp @@ -49,12 +49,11 @@ class TuneTranspose { static size_t DefaultBatchCount() { return 1; } // N/A for this kernel static double DefaultFraction() { return 1.0; } // N/A for this kernel static size_t DefaultNumRuns() { return 10; } // run every kernel this many times for averaging - static size_t DefaultNumSearchStragegy() { return 1; } // N/A for this kernel static size_t DefaultSwarmSizePSO() { return 8; } // N/A for this kernel static double DefaultInfluenceGlobalPSO(){ return 0.1; }// N/A for this kernel static double DefaultInfluenceLocalPSO(){ return 0.3; }// N/A for this kernel static double DefaultInfluenceRandomPSO(){ return 0.6; }// N/A for this kernel - static size_t DefaultHeuristic(){ return size_t{0};} // Full search + static size_t DefaultHeuristic(){ return static_cast (cltune::SearchMethod::FullSearch);} static double DefaultMaxTempAnn(){ return 1.0;}// N/A for this kernel // Describes how to obtain the sizes of the buffers @@ -113,8 +112,8 @@ class TuneTranspose { static std::string PerformanceUnit() { return "GB/s"; } // Returns which Heuristic to run - static size_t GetCurrentHeuristic(const Arguments &args){ - return size_t{0}; // Full search + static size_t GetHeuristic(const Arguments &args){ + return static_cast (cltune::SearchMethod::FullSearch); } }; diff --git a/src/tuning/kernels/transpose_pad.cpp b/src/tuning/kernels/transpose_pad.cpp index a1695c9f..304702de 100644 --- a/src/tuning/kernels/transpose_pad.cpp +++ b/src/tuning/kernels/transpose_pad.cpp @@ -49,12 +49,11 @@ class TunePadTranspose { static size_t DefaultBatchCount() { return 1; } // N/A for this kernel static double DefaultFraction() { return 1.0; } // N/A for this kernel static size_t DefaultNumRuns() { return 10; } // run every kernel this many times for averaging - static size_t DefaultNumSearchStragegy() { return 1; }// N/A for this kernel static size_t DefaultSwarmSizePSO() { return 8; } // N/A for this kernel static double DefaultInfluenceGlobalPSO(){ return 0.1; }// N/A for this kernel static double DefaultInfluenceLocalPSO(){ return 0.3; }// N/A for this kernel static double DefaultInfluenceRandomPSO(){ return 0.6; }// N/A for this kernel - static size_t DefaultHeuristic(){ return size_t{0};} // N/A for this kernel + static size_t DefaultHeuristic(){ return static_cast (cltune::SearchMethod::FullSearch);} static double DefaultMaxTempAnn(){ return 1.0;}// N/A for this kernel // Describes how to obtain the sizes of the buffers @@ -120,8 +119,8 @@ class TunePadTranspose { static std::string PerformanceUnit() { return "GB/s"; } // Returns which Heuristic to run - static size_t GetCurrentHeuristic(const Arguments &args){ - return size_t{0}; // Full search + static size_t GetHeuristic(const Arguments &args){ + return static_cast (cltune::SearchMethod::FullSearch); } }; diff --git a/src/tuning/kernels/xaxpy.cpp b/src/tuning/kernels/xaxpy.cpp index a8a9457d..f8e1d93e 100644 --- a/src/tuning/kernels/xaxpy.cpp +++ b/src/tuning/kernels/xaxpy.cpp @@ -53,12 +53,11 @@ class TuneXaxpy { static size_t DefaultBatchCount() { return 1; } // N/A for this kernel static double DefaultFraction() { return 1.0; } // N/A for this kernel static size_t DefaultNumRuns() { return 10; } // run every kernel this many times for averaging - static size_t DefaultNumSearchStragegy() { return 1; } // N/A for this kernel static size_t DefaultSwarmSizePSO() { return 8; } // N/A for this kernel static double DefaultInfluenceGlobalPSO(){ return 0.1; }// N/A for this kernel static double DefaultInfluenceLocalPSO(){ return 0.3; }// N/A for this kernel static double DefaultInfluenceRandomPSO(){ return 0.6; }// N/A for this kernel - static size_t DefaultHeuristic(){ return size_t{0};} // Full search + static size_t DefaultHeuristic(){ return static_cast (cltune::SearchMethod::FullSearch);} static double DefaultMaxTempAnn(){ return 1.0;} // N/A for this kernel // Describes how to obtain the sizes of the buffers @@ -111,8 +110,8 @@ class TuneXaxpy { static std::string PerformanceUnit() { return "GB/s"; } // Returns which Heuristic to run - static size_t GetCurrentHeuristic(const Arguments &args){ - return size_t{0}; // Full search + static size_t GetHeuristic(const Arguments &args){ + return static_cast (cltune::SearchMethod::FullSearch); } }; diff --git a/src/tuning/kernels/xdot.cpp b/src/tuning/kernels/xdot.cpp index f70fafb3..c3b5361e 100644 --- a/src/tuning/kernels/xdot.cpp +++ b/src/tuning/kernels/xdot.cpp @@ -49,12 +49,11 @@ class TuneXdot { static size_t DefaultBatchCount() { return 1; } // N/A for this kernel static double DefaultFraction() { return 1.0; } // N/A for this kernel static size_t DefaultNumRuns() { return 10; } // run every kernel this many times for averaging - static size_t DefaultNumSearchStragegy() { return 1; } // N/A for this kernel static size_t DefaultSwarmSizePSO() { return 8; } // N/A for this kernel static double DefaultInfluenceGlobalPSO(){ return 0.1; }// N/A for this kernel static double DefaultInfluenceLocalPSO(){ return 0.3; }// N/A for this kernel static double DefaultInfluenceRandomPSO(){ return 0.6; }// N/A for this kernel - static size_t DefaultHeuristic(){ return size_t{0};} // Full search + static size_t DefaultHeuristic(){ return static_cast (cltune::SearchMethod::FullSearch);} static double DefaultMaxTempAnn(){ return 1.0;}// N/A for this kernel // Describes how to obtain the sizes of the buffers @@ -117,8 +116,8 @@ class TuneXdot { static std::string PerformanceUnit() { return (V==1) ? "GB/s" : "N/A"; } // Returns which Heuristic to run - static size_t GetCurrentHeuristic(const Arguments &args){ - return size_t{0}; + static size_t GetHeuristic(const Arguments &args){ + return static_cast (cltune::SearchMethod::FullSearch); } }; diff --git a/src/tuning/kernels/xgemm.cpp b/src/tuning/kernels/xgemm.cpp index 98d3b68b..063a3bae 100644 --- a/src/tuning/kernels/xgemm.cpp +++ b/src/tuning/kernels/xgemm.cpp @@ -30,7 +30,7 @@ class TuneXgemm { // The representative kernel and the source code // static std::string KernelFamily() { return (V==1) ? "xgemm_1" : "xgemm_2"; } - static std::string KernelFamily() { switch(V){ case 1: return "xgemm_1"; case 2: case 3:return "xgemm_2"; }} + static std::string KernelFamily() { switch(V){ case 1: return "xgemm_1"; case 2: return "xgemm_2"; }} static std::string KernelName() { return "Xgemm"; } static std::string GetSources() { return @@ -44,7 +44,7 @@ class TuneXgemm { // The list of arguments relevant for this routine static std::vector GetOptions() { return {kArgM, kArgN, kArgK, kArgAlpha, kArgBeta, kArgFraction, - kArgHeuristicSelection, kArgMultiSearchStrategy, kArgPsoSwarmSize, + kArgHeuristicSelection, kArgPsoSwarmSize, kArgPsoInfGlobal, kArgPsoInfLocal, kArgPsoInfRandom}; } @@ -58,12 +58,11 @@ class TuneXgemm { static size_t DefaultBatchCount() { return 1; } // N/A for this kernel static double DefaultFraction() { return (V==1) ? 1.0 : 512.0; } // test all or sample randomly static size_t DefaultNumRuns() { return 2; } // run every kernel this many times for averaging - static size_t DefaultNumSearchStragegy() { return 2; } // Full search and Random/PSO static size_t DefaultSwarmSizePSO() { return 8; } static double DefaultInfluenceGlobalPSO(){ return 0.1; } static double DefaultInfluenceLocalPSO(){ return 0.3; } static double DefaultInfluenceRandomPSO(){ return 0.6; } - static size_t DefaultHeuristic(){ return (size_t)cltune::SearchMethod::PSO;} // PSO + static size_t DefaultHeuristic(){ return static_cast (cltune::SearchMethod::PSO);} static double DefaultMaxTempAnn(){ return 1.0;} // Describes how to obtain the sizes of the buffers @@ -180,29 +179,18 @@ class TuneXgemm { return 2 * args.m * args.n * args.k; } static std::string PerformanceUnit() { return "GFLOPS"; } - + // Returns which Heuristic to run - static size_t GetCurrentHeuristic(const Arguments &args){ - - // Multi Search Strategy is enable - if( args.multi_search_strategy){ - if( V == 1){ - return (size_t) cltune::SearchMethod::FullSearch; - } - else{ - return args.heuristic_selection; - } - } - + static size_t GetHeuristic(const Arguments &args){ // Use full-search to explore all parameter combinations or random-search to search only a part of // the parameter values. The fraction is set as a command-line argument. if (args.fraction == 1.0 || args.fraction == 0.0) { - return (size_t) cltune::SearchMethod::FullSearch; + return static_cast (cltune::SearchMethod::FullSearch); } else { return args.heuristic_selection; } - } + } }; // ================================================================================================= @@ -226,35 +214,6 @@ void StartVariation(int argc, char *argv[]) { } } -// Test multiple heuristics if kArgMultiSearchStrategy is enabled -// Otherwise, run the heuristic specified in kArgMultiSearchStrategy -void TestHeuristic(int argc, char *argv[]){ - - auto command_line_args = clblast::RetrieveCommandLineArguments(argc, argv); - auto help = std::string{""}; - auto heuristic_selected = clblast::GetArgument(command_line_args, help, clblast::kArgMultiSearchStrategy, 0); - auto multi_search_strategy = clblast::GetArgument(command_line_args, help, clblast::kArgMultiSearchStrategy, 0); - - if(multi_search_strategy){ - StartVariation<1>(argc, argv); - StartVariation<2>(argc, argv); - } - else - { - switch(heuristic_selected){ - case 1: - case 2: - case 3: - StartVariation<2>(argc, argv); - break; - case 0: - default: - StartVariation<1>(argc, argv); - break; - } - } -} - // Main function (not within the clblast namespace) int main(int argc, char *argv[]) { StartVariation<1>(argc, argv); diff --git a/src/tuning/kernels/xgemm_direct.cpp b/src/tuning/kernels/xgemm_direct.cpp index 3fb4ff34..3de19496 100644 --- a/src/tuning/kernels/xgemm_direct.cpp +++ b/src/tuning/kernels/xgemm_direct.cpp @@ -42,7 +42,7 @@ class TuneXgemmDirect { // The list of arguments relevant for this routine static std::vector GetOptions() { return {kArgM, kArgN, kArgK, kArgAlpha, kArgBeta, kArgFraction, - kArgHeuristicSelection, kArgMultiSearchStrategy, kArgPsoSwarmSize, + kArgHeuristicSelection, kArgPsoSwarmSize, kArgPsoInfGlobal, kArgPsoInfLocal, kArgPsoInfRandom}; } @@ -56,12 +56,11 @@ class TuneXgemmDirect { static size_t DefaultBatchCount() { return 1; } // N/A for this kernel static double DefaultFraction() { return (V==1) ? 1.0 : 32.0; } // test all or sample randomly static size_t DefaultNumRuns() { return 4; } // run every kernel this many times for averaging - static size_t DefaultNumSearchStragegy() { return 2; } // Full search and Random/PSO static size_t DefaultSwarmSizePSO() { return 8; } static double DefaultInfluenceGlobalPSO(){ return 0.1; } static double DefaultInfluenceLocalPSO(){ return 0.3; } static double DefaultInfluenceRandomPSO(){ return 0.6; } - static size_t DefaultHeuristic(){ return size_t{3};} // PSO + static size_t DefaultHeuristic(){ return static_cast(cltune::SearchMethod::PSO);} static double DefaultMaxTempAnn(){ return 1.0;} // Describes how to obtain the sizes of the buffers @@ -177,22 +176,11 @@ class TuneXgemmDirect { static std::string PerformanceUnit() { return "GFLOPS"; } // Returns which Heuristic to run - static size_t GetCurrentHeuristic(const Arguments &args){ - - // Multi Search Strategy is enable - if( args.multi_search_strategy){ - if( V == 1){ - return size_t{0}; - } - else{ - return args.heuristic_selection; - } - } - + static size_t GetHeuristic(const Arguments &args){ // Use full-search to explore all parameter combinations or random-search to search only a part of // the parameter values. The fraction is set as a command-line argument. if (args.fraction == 1.0 || args.fraction == 0.0) { - return size_t{0}; // Full search + return static_cast (cltune::SearchMethod::FullSearch); } else { return args.heuristic_selection; @@ -220,34 +208,6 @@ void StartVariation(int argc, char *argv[]) { case clblast::Precision::kComplexDouble: clblast::Tuner, double2>(argc, argv); break; } } -// Test multiple heuristics if kArgMultiSearchStrategy is enabled -// Otherwise, run the heuristic specified in kArgMultiSearchStrategy -void TestHeuristic(int argc, char *argv[]){ - - auto command_line_args = clblast::RetrieveCommandLineArguments(argc, argv); - auto help = std::string{""}; - auto heuristic_selected = clblast::GetArgument(command_line_args, help, clblast::kArgMultiSearchStrategy, 0); - auto multi_search_strategy = clblast::GetArgument(command_line_args, help, clblast::kArgMultiSearchStrategy, 0); - - if(multi_search_strategy){ - StartVariation<1>(argc, argv); - StartVariation<2>(argc, argv); - } - else - { - switch(heuristic_selected){ - case 1: - case 2: - case 3: - StartVariation<2>(argc, argv); - break; - case 0: - default: - StartVariation<1>(argc, argv); - break; - } - } -} // Main function (not within the clblast namespace) int main(int argc, char *argv[]) { diff --git a/src/tuning/kernels/xgemv.cpp b/src/tuning/kernels/xgemv.cpp index 7d23eeec..00115b6c 100644 --- a/src/tuning/kernels/xgemv.cpp +++ b/src/tuning/kernels/xgemv.cpp @@ -52,12 +52,11 @@ class TuneXgemv { static size_t DefaultBatchCount() { return 1; } // N/A for this kernel static double DefaultFraction() { return 1.0; } // N/A for this kernel static size_t DefaultNumRuns() { return 10; } // run every kernel this many times for averaging - static size_t DefaultNumSearchStragegy() { return 1; } // N/A for this kernel static size_t DefaultSwarmSizePSO() { return 8; } // N/A for this kernel static double DefaultInfluenceGlobalPSO(){ return 0.1; }// N/A for this kernel static double DefaultInfluenceLocalPSO(){ return 0.3; }// N/A for this kernel static double DefaultInfluenceRandomPSO(){ return 0.6; }// N/A for this kernel - static size_t DefaultHeuristic(){ return size_t{0};} // Full search + static size_t DefaultHeuristic(){ return static_cast (cltune::SearchMethod::FullSearch);} static double DefaultMaxTempAnn(){ return 1.0;}// N/A for this kernel // Describes how to obtain the sizes of the buffers @@ -157,8 +156,8 @@ class TuneXgemv { static std::string PerformanceUnit() { return "GB/s"; } // Returns which Heuristic to run - static size_t GetCurrentHeuristic(const Arguments &args){ - return size_t{0}; //Full search + static size_t GetHeuristic(const Arguments &args){ + return static_cast (cltune::SearchMethod::FullSearch); } }; diff --git a/src/tuning/kernels/xger.cpp b/src/tuning/kernels/xger.cpp index 09c5ba3f..14a98761 100644 --- a/src/tuning/kernels/xger.cpp +++ b/src/tuning/kernels/xger.cpp @@ -49,12 +49,11 @@ class TuneXger { static size_t DefaultBatchCount() { return 1; } // N/A for this kernel static double DefaultFraction() { return 1.0; } // N/A for this kernel static size_t DefaultNumRuns() { return 10; } // run every kernel this many times for averaging - static size_t DefaultNumSearchStragegy() { return 1; } // N/A for this kernel static size_t DefaultSwarmSizePSO() { return 8; } // N/A for this kernel static double DefaultInfluenceGlobalPSO(){ return 0.1; }// N/A for this kernel static double DefaultInfluenceLocalPSO(){ return 0.3; } // N/A for this kernel static double DefaultInfluenceRandomPSO(){ return 0.6; }// N/A for this kernel - static size_t DefaultHeuristic(){ return size_t{0};}// Full search + static size_t DefaultHeuristic(){ return static_cast (cltune::SearchMethod::FullSearch);} static double DefaultMaxTempAnn(){ return 1.0;}// N/A for this kernel // Describes how to obtain the sizes of the buffers @@ -116,8 +115,8 @@ class TuneXger { static std::string PerformanceUnit() { return "GB/s"; } // Returns which Heuristic to run - static size_t GetCurrentHeuristic(const Arguments &args){ - return size_t{0}; // Full search + static size_t GetHeuristic(const Arguments &args){ + return static_cast (cltune::SearchMethod::FullSearch); } }; diff --git a/src/tuning/tuning.hpp b/src/tuning/tuning.hpp index 2e0eb5a1..6a8039d2 100644 --- a/src/tuning/tuning.hpp +++ b/src/tuning/tuning.hpp @@ -49,7 +49,6 @@ void Tuner(int argc, char* argv[]) { if (o == kArgFraction) { args.fraction = GetArgument(command_line_args, help, kArgFraction, C::DefaultFraction()); } if (o == kArgBatchCount) { args.batch_count = GetArgument(command_line_args, help, kArgBatchCount, C::DefaultBatchCount()); } if (o == kArgHeuristicSelection) {args.heuristic_selection = GetArgument(command_line_args, help, kArgHeuristicSelection, C::DefaultHeuristic()); } - if (o == kArgMultiSearchStrategy) {args.multi_search_strategy = GetArgument(command_line_args, help, kArgMultiSearchStrategy, 0);} if (o == kArgPsoSwarmSize) {args.pso_swarm_size = GetArgument(command_line_args, help, kArgPsoSwarmSize , C::DefaultSwarmSizePSO()); } if (o == kArgPsoInfGlobal) {args.pso_inf_global = GetArgument(command_line_args, help, kArgPsoInfGlobal, C::DefaultInfluenceGlobalPSO()); } if (o == kArgPsoInfLocal) {args.pso_inf_local = GetArgument(command_line_args, help, kArgPsoInfLocal, C::DefaultInfluenceLocalPSO()); } @@ -100,7 +99,7 @@ void Tuner(int argc, char* argv[]) { // Select the search method based on the cmd_line arguments // If the tuner does not support the selected choice, Full Search will be returned. - auto method = C::GetCurrentHeuristic(args); + auto method = C::GetHeuristic(args); if (method == 1) { tuner.UseRandomSearch(1.0/args.fraction); } else if (method == 2) { tuner.UseAnnealing(args.fraction, args.ann_max_temperature); } diff --git a/src/utilities/utilities.hpp b/src/utilities/utilities.hpp index e7e95bbb..006450c8 100644 --- a/src/utilities/utilities.hpp +++ b/src/utilities/utilities.hpp @@ -81,7 +81,6 @@ constexpr auto kArgBatchCount = "batch_num"; // The tuner-specific arguments in string form constexpr auto kArgFraction = "fraction"; constexpr auto kArgHeuristicSelection = "heuristic"; -constexpr auto kArgMultiSearchStrategy = "multi_strategy"; // PSO tuner-specific arguments in string form constexpr auto kArgPsoSwarmSize = "pso_swarm_size"; constexpr auto kArgPsoInfGlobal = "pso_inf_global"; @@ -198,7 +197,6 @@ struct Arguments { size_t scalar_size = 1; // Tuner-specific arguments size_t heuristic_selection = 0; - size_t multi_search_strategy = 0; double fraction = 1.0; size_t pso_swarm_size = 8; double pso_inf_global = 0.3; -- cgit v1.2.3