Separate kernel tuners in .cpp with main and .hpp with settings
parent
269bddbf34
commit
a1cedf36e3
|
@ -11,86 +11,7 @@
|
|||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgAlpha};
|
||||
settings.default_m = 1024;
|
||||
settings.default_n = 1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "copy";
|
||||
settings.kernel_name = "CopyMatrixFast";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level3/level3.opencl"
|
||||
#include "../src/kernels/level3/copy_fast.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.m * args.n;
|
||||
settings.size_b = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3};
|
||||
settings.outputs = {3};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"COPY_DIMX", "COPY_DIMY"}};
|
||||
settings.div_global = {{"COPY_VW", "COPY_WPT"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"COPY_DIMX", {8, 16, 32}},
|
||||
{"COPY_DIMY", {8, 16, 32}},
|
||||
{"COPY_WPT", {1, 2, 4, 8}},
|
||||
{"COPY_VW", {1, 2, 4, 8}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 2 * args.m * args.n * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(2, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(3, GetRealArg(args.alpha));
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
#include "tuning/kernels/copy_fast.hpp"
|
||||
|
||||
// Shortcuts to the clblast namespace
|
||||
using half = clblast::half;
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
// =================================================================================================
|
||||
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
||||
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
||||
// width of 100 characters per line.
|
||||
//
|
||||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the copy OpenCL kernels.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgAlpha};
|
||||
settings.default_m = 1024;
|
||||
settings.default_n = 1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "copy";
|
||||
settings.kernel_name = "CopyMatrixFast";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level3/level3.opencl"
|
||||
#include "../src/kernels/level3/copy_fast.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.m * args.n;
|
||||
settings.size_b = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3};
|
||||
settings.outputs = {3};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"COPY_DIMX", "COPY_DIMY"}};
|
||||
settings.div_global = {{"COPY_VW", "COPY_WPT"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"COPY_DIMX", {8, 16, 32}},
|
||||
{"COPY_DIMY", {8, 16, 32}},
|
||||
{"COPY_WPT", {1, 2, 4, 8}},
|
||||
{"COPY_VW", {1, 2, 4, 8}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 2 * args.m * args.n * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(2, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(3, GetRealArg(args.alpha));
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
|
@ -11,94 +11,7 @@
|
|||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgAlpha};
|
||||
settings.default_m = 1024;
|
||||
settings.default_n = 1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "pad";
|
||||
settings.kernel_name = "CopyPadMatrix";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level3/level3.opencl"
|
||||
#include "../src/kernels/level3/copy_pad.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.m * args.n;
|
||||
settings.size_b = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3};
|
||||
settings.outputs = {3};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"PAD_DIMX", "PAD_DIMY"}};
|
||||
settings.div_global = {{"PAD_WPTX", "PAD_WPTY"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"PAD_DIMX", {8, 16, 32}},
|
||||
{"PAD_DIMY", {8, 16, 32}},
|
||||
{"PAD_WPTX", {1, 2, 4}},
|
||||
{"PAD_WPTY", {1, 2, 4}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 2 * args.m * args.n * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, static_cast<int>(args.n));
|
||||
kernel.SetArgument(2, static_cast<int>(args.m));
|
||||
kernel.SetArgument(3, 0);
|
||||
kernel.SetArgument(4, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(5, static_cast<int>(args.m));
|
||||
kernel.SetArgument(6, static_cast<int>(args.n));
|
||||
kernel.SetArgument(7, static_cast<int>(args.m));
|
||||
kernel.SetArgument(8, 0);
|
||||
kernel.SetArgument(9, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(10, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(11, 0);
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
#include "tuning/kernels/copy_pad.hpp"
|
||||
|
||||
// Shortcuts to the clblast namespace
|
||||
using half = clblast::half;
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
|
||||
// =================================================================================================
|
||||
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
||||
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
||||
// width of 100 characters per line.
|
||||
//
|
||||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the pad OpenCL kernels.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgAlpha};
|
||||
settings.default_m = 1024;
|
||||
settings.default_n = 1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "pad";
|
||||
settings.kernel_name = "CopyPadMatrix";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level3/level3.opencl"
|
||||
#include "../src/kernels/level3/copy_pad.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.m * args.n;
|
||||
settings.size_b = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3};
|
||||
settings.outputs = {3};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"PAD_DIMX", "PAD_DIMY"}};
|
||||
settings.div_global = {{"PAD_WPTX", "PAD_WPTY"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"PAD_DIMX", {8, 16, 32}},
|
||||
{"PAD_DIMY", {8, 16, 32}},
|
||||
{"PAD_WPTX", {1, 2, 4}},
|
||||
{"PAD_WPTY", {1, 2, 4}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 2 * args.m * args.n * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, static_cast<int>(args.n));
|
||||
kernel.SetArgument(2, static_cast<int>(args.m));
|
||||
kernel.SetArgument(3, 0);
|
||||
kernel.SetArgument(4, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(5, static_cast<int>(args.m));
|
||||
kernel.SetArgument(6, static_cast<int>(args.n));
|
||||
kernel.SetArgument(7, static_cast<int>(args.m));
|
||||
kernel.SetArgument(8, 0);
|
||||
kernel.SetArgument(9, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(10, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(11, 0);
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
|
@ -11,99 +11,7 @@
|
|||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgN, kArgM, kArgK};
|
||||
settings.default_n = 128; // dimension of input matrix 'n'
|
||||
settings.default_m = 64; // block size
|
||||
settings.default_k = 16; // current size
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "invert";
|
||||
settings.kernel_name = "TripleMatMul16Part1Lower";
|
||||
settings.sources =
|
||||
"#define ROUTINE_INVERT"
|
||||
#include "../src/kernels/level3/invert_diagonal_blocks_part1.opencl"
|
||||
#include "../src/kernels/level3/invert_diagonal_blocks_part2.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.n * args.n + args.a_offset;
|
||||
settings.size_b = Ceil(args.n, args.m) * args.m; // Ceil(n, block_size) * block_size
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3};
|
||||
settings.outputs = {3};
|
||||
|
||||
// Sets the base thread configuration
|
||||
const auto num_pages = CeilDiv(args.n, args.k * 2); // CeilDiv(n, current_size*2)
|
||||
settings.global_size = {args.k / 4, num_pages * (args.k / 16) * 4};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {4, 4};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"TMMWGSX", "TMMWGSY"}};
|
||||
settings.div_global = {{}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
// TODO: Make these actually tunable, apart from LOCALPAD
|
||||
settings.parameters = {
|
||||
{"INTERNAL_BLOCK_SIZE", {16}},
|
||||
{"LOCALPAD", {0, 1}},
|
||||
{"TMMWGSX", {4}},
|
||||
{"TMMWGSY", {4}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 1 * GetBytes(args.precision);
|
||||
settings.performance_unit = "N/A";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &args) {
|
||||
if (!(args.k == 16)) {
|
||||
throw std::runtime_error("'TripleMatMul16Part1Lower' requires 'k' to be 16");
|
||||
}
|
||||
}
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
const auto num_pages = CeilDiv(args.n, args.k * 2); // CeilDiv(n, current_size*2)
|
||||
kernel.SetArgument(0, static_cast<int>(args.n)); // n
|
||||
kernel.SetArgument(1, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(2, 0); // a_offset
|
||||
kernel.SetArgument(3, static_cast<int>(args.n)); // a_ld
|
||||
kernel.SetArgument(4, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(5, static_cast<int>(args.k)); // current_size
|
||||
kernel.SetArgument(6, static_cast<int>(num_pages)); // num_pages
|
||||
kernel.SetArgument(7, static_cast<int>(args.m)); // block_size
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
#include "tuning/kernels/invert.hpp"
|
||||
|
||||
// Shortcuts to the clblast namespace
|
||||
using half = clblast::half;
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
|
||||
// =================================================================================================
|
||||
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
||||
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
||||
// width of 100 characters per line.
|
||||
//
|
||||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the invert OpenCL kernels.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgN, kArgM, kArgK};
|
||||
settings.default_n = 128; // dimension of input matrix 'n'
|
||||
settings.default_m = 64; // block size
|
||||
settings.default_k = 16; // current size
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "invert";
|
||||
settings.kernel_name = "TripleMatMul16Part1Lower";
|
||||
settings.sources =
|
||||
"#define ROUTINE_INVERT"
|
||||
#include "../src/kernels/level3/invert_diagonal_blocks_part1.opencl"
|
||||
#include "../src/kernels/level3/invert_diagonal_blocks_part2.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.n * args.n + args.a_offset;
|
||||
settings.size_b = Ceil(args.n, args.m) * args.m; // Ceil(n, block_size) * block_size
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3};
|
||||
settings.outputs = {3};
|
||||
|
||||
// Sets the base thread configuration
|
||||
const auto num_pages = CeilDiv(args.n, args.k * 2); // CeilDiv(n, current_size*2)
|
||||
settings.global_size = {args.k / 4, num_pages * (args.k / 16) * 4};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {4, 4};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"TMMWGSX", "TMMWGSY"}};
|
||||
settings.div_global = {{}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
// TODO: Make these actually tunable, apart from LOCALPAD
|
||||
settings.parameters = {
|
||||
{"INTERNAL_BLOCK_SIZE", {16}},
|
||||
{"LOCALPAD", {0, 1}},
|
||||
{"TMMWGSX", {4}},
|
||||
{"TMMWGSY", {4}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 1 * GetBytes(args.precision);
|
||||
settings.performance_unit = "N/A";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &args) {
|
||||
if (!(args.k == 16)) {
|
||||
throw std::runtime_error("'TripleMatMul16Part1Lower' requires 'k' to be 16");
|
||||
}
|
||||
}
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
const auto num_pages = CeilDiv(args.n, args.k * 2); // CeilDiv(n, current_size*2)
|
||||
kernel.SetArgument(0, static_cast<int>(args.n)); // n
|
||||
kernel.SetArgument(1, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(2, 0); // a_offset
|
||||
kernel.SetArgument(3, static_cast<int>(args.n)); // a_ld
|
||||
kernel.SetArgument(4, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(5, static_cast<int>(args.k)); // current_size
|
||||
kernel.SetArgument(6, static_cast<int>(num_pages)); // num_pages
|
||||
kernel.SetArgument(7, static_cast<int>(args.m)); // block_size
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
|
@ -11,86 +11,7 @@
|
|||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgAlpha};
|
||||
settings.default_m = 1024;
|
||||
settings.default_n = 1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "transpose";
|
||||
settings.kernel_name = "TransposeMatrixFast";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level3/level3.opencl"
|
||||
#include "../src/kernels/level3/transpose_fast.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.m * args.n;
|
||||
settings.size_b = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3};
|
||||
settings.outputs = {3};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"TRA_DIM", "TRA_DIM"}};
|
||||
settings.div_global = {{"TRA_WPT", "TRA_WPT"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"TRA_DIM", {4, 8, 16, 32, 64}},
|
||||
{"TRA_WPT", {1, 2, 4, 8, 16}},
|
||||
{"TRA_PAD", {0, 1}},
|
||||
{"TRA_SHUFFLE", {0, 1}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 2 * args.m * args.n * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(2, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(3, GetRealArg(args.alpha));
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
#include "tuning/kernels/transpose_fast.hpp"
|
||||
|
||||
// Shortcuts to the clblast namespace
|
||||
using half = clblast::half;
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
// =================================================================================================
|
||||
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
||||
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
||||
// width of 100 characters per line.
|
||||
//
|
||||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the transpose OpenCL kernels.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgAlpha};
|
||||
settings.default_m = 1024;
|
||||
settings.default_n = 1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "transpose";
|
||||
settings.kernel_name = "TransposeMatrixFast";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level3/level3.opencl"
|
||||
#include "../src/kernels/level3/transpose_fast.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.m * args.n;
|
||||
settings.size_b = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3};
|
||||
settings.outputs = {3};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"TRA_DIM", "TRA_DIM"}};
|
||||
settings.div_global = {{"TRA_WPT", "TRA_WPT"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"TRA_DIM", {4, 8, 16, 32, 64}},
|
||||
{"TRA_WPT", {1, 2, 4, 8, 16}},
|
||||
{"TRA_PAD", {0, 1}},
|
||||
{"TRA_SHUFFLE", {0, 1}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 2 * args.m * args.n * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(2, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(3, GetRealArg(args.alpha));
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
|
@ -11,93 +11,7 @@
|
|||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgAlpha};
|
||||
settings.default_m = 1024;
|
||||
settings.default_n = 1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "padtranspose";
|
||||
settings.kernel_name = "TransposePadMatrix";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level3/level3.opencl"
|
||||
#include "../src/kernels/level3/transpose_pad.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.m * args.n;
|
||||
settings.size_b = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3};
|
||||
settings.outputs = {3};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"PADTRA_TILE", "PADTRA_TILE"}};
|
||||
settings.div_global = {{"PADTRA_WPT", "PADTRA_WPT"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"PADTRA_TILE", {8, 16, 32, 64}},
|
||||
{"PADTRA_WPT", {1, 2, 4, 8, 16}},
|
||||
{"PADTRA_PAD", {0, 1}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 2 * args.m * args.n * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, static_cast<int>(args.n));
|
||||
kernel.SetArgument(2, static_cast<int>(args.m));
|
||||
kernel.SetArgument(3, 0);
|
||||
kernel.SetArgument(4, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(5, static_cast<int>(args.n));
|
||||
kernel.SetArgument(6, static_cast<int>(args.m));
|
||||
kernel.SetArgument(7, static_cast<int>(args.n));
|
||||
kernel.SetArgument(8, 0);
|
||||
kernel.SetArgument(9, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(10, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(11, 0);
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
#include "tuning/kernels/transpose_pad.hpp"
|
||||
|
||||
// Shortcuts to the clblast namespace
|
||||
using half = clblast::half;
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
|
||||
// =================================================================================================
|
||||
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
||||
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
||||
// width of 100 characters per line.
|
||||
//
|
||||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the pad-transpose OpenCL kernels.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgAlpha};
|
||||
settings.default_m = 1024;
|
||||
settings.default_n = 1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "padtranspose";
|
||||
settings.kernel_name = "TransposePadMatrix";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level3/level3.opencl"
|
||||
#include "../src/kernels/level3/transpose_pad.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.m * args.n;
|
||||
settings.size_b = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3};
|
||||
settings.outputs = {3};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"PADTRA_TILE", "PADTRA_TILE"}};
|
||||
settings.div_global = {{"PADTRA_WPT", "PADTRA_WPT"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"PADTRA_TILE", {8, 16, 32, 64}},
|
||||
{"PADTRA_WPT", {1, 2, 4, 8, 16}},
|
||||
{"PADTRA_PAD", {0, 1}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 2 * args.m * args.n * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, static_cast<int>(args.n));
|
||||
kernel.SetArgument(2, static_cast<int>(args.m));
|
||||
kernel.SetArgument(3, 0);
|
||||
kernel.SetArgument(4, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(5, static_cast<int>(args.n));
|
||||
kernel.SetArgument(6, static_cast<int>(args.m));
|
||||
kernel.SetArgument(7, static_cast<int>(args.n));
|
||||
kernel.SetArgument(8, 0);
|
||||
kernel.SetArgument(9, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(10, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(11, 0);
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
|
@ -11,88 +11,7 @@
|
|||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgN, kArgAlpha};
|
||||
settings.default_n = 4096*1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "xaxpy";
|
||||
settings.kernel_name = "XaxpyFastest";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level1/level1.opencl"
|
||||
#include "../src/kernels/level1/xaxpy.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_x = args.n;
|
||||
settings.size_y = args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {0, 1};
|
||||
settings.outputs = {1};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1};
|
||||
settings.local_size_ref = {64};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"WGS"}};
|
||||
settings.div_global = {{"WPT"},{"VW"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"WGS", {64, 128, 256, 512, 1024, 2048}},
|
||||
{"WPT", {1, 2, 4, 8}},
|
||||
{"VW", {1, 2, 4, 8}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 3 * args.n * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &args) {
|
||||
if (!IsMultiple(args.n, 64)) {
|
||||
throw std::runtime_error("'XaxpyFastest' requires 'n' to be a multiple of WGS*WPT*VW");
|
||||
}
|
||||
}
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.n));
|
||||
kernel.SetArgument(1, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(2, buffers[0]()); // 0 == X vector
|
||||
kernel.SetArgument(3, buffers[1]()); // 1 == Y vector
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
#include "tuning/kernels/xaxpy.hpp"
|
||||
|
||||
// Shortcuts to the clblast namespace
|
||||
using half = clblast::half;
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
|
||||
// =================================================================================================
|
||||
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
||||
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
||||
// width of 100 characters per line.
|
||||
//
|
||||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the xaxpy OpenCL kernels.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgN, kArgAlpha};
|
||||
settings.default_n = 4096*1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "xaxpy";
|
||||
settings.kernel_name = "XaxpyFastest";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level1/level1.opencl"
|
||||
#include "../src/kernels/level1/xaxpy.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_x = args.n;
|
||||
settings.size_y = args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {0, 1};
|
||||
settings.outputs = {1};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1};
|
||||
settings.local_size_ref = {64};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"WGS"}};
|
||||
settings.div_global = {{"WPT"},{"VW"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"WGS", {64, 128, 256, 512, 1024, 2048}},
|
||||
{"WPT", {1, 2, 4, 8}},
|
||||
{"VW", {1, 2, 4, 8}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 3 * args.n * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &args) {
|
||||
if (!IsMultiple(args.n, 64)) {
|
||||
throw std::runtime_error("'XaxpyFastest' requires 'n' to be a multiple of WGS*WPT*VW");
|
||||
}
|
||||
}
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.n));
|
||||
kernel.SetArgument(1, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(2, buffers[0]()); // 0 == X vector
|
||||
kernel.SetArgument(3, buffers[1]()); // 1 == Y vector
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
|
@ -12,94 +12,7 @@
|
|||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgN};
|
||||
settings.default_n = 2*1024*1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int V, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "xdot_"+std::to_string(V);
|
||||
settings.kernel_name = (V==1) ? "Xdot" : "XdotEpilogue";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level1/xdot.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_x = args.n;
|
||||
settings.size_y = args.n;
|
||||
settings.size_temp = args.n; // Worst case
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {0, 1, 5};
|
||||
settings.outputs = {}; // no output checking
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = (V==1) ? std::vector<size_t>{2*64} : std::vector<size_t>{1};
|
||||
settings.global_size_ref = (V==1) ? std::vector<size_t>{2*64*64} : std::vector<size_t>{64};
|
||||
settings.local_size = {1};
|
||||
settings.local_size_ref = {64};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = (V==1) ? TransformVector{{"WGS1"}} : TransformVector{{"WGS2"}};
|
||||
settings.mul_global = (V==1) ? TransformVector{{"WGS1"}} : TransformVector{{"WGS2"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"WGS"+std::to_string(V), {32, 64, 128, 256, 512, 1024}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = (V==1) ? (2*args.n + 1) * GetBytes(args.precision) : 1 * GetBytes(args.precision);
|
||||
settings.performance_unit = (V==1) ? "GB/s" : "N/A";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int V, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
if (V == 1) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.n));
|
||||
kernel.SetArgument(1, buffers[0]()); // 0 == X vector
|
||||
kernel.SetArgument(2, 0);
|
||||
kernel.SetArgument(3, 1);
|
||||
kernel.SetArgument(4, buffers[1]()); // 1 == Y vector
|
||||
kernel.SetArgument(5, 0);
|
||||
kernel.SetArgument(6, 1);
|
||||
kernel.SetArgument(7, buffers[5]()); // 5 == temp; no output checking - size varies
|
||||
kernel.SetArgument(8, static_cast<int>(false));
|
||||
}
|
||||
else {
|
||||
kernel.SetArgument(0, buffers[5]()); // 5 == temp
|
||||
kernel.SetArgument(1, buffers[0]()); // 0 == X vector; no output checking - size varies
|
||||
kernel.SetArgument(2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
#include "tuning/kernels/xdot.hpp"
|
||||
|
||||
// Shortcuts to the clblast namespace
|
||||
using half = clblast::half;
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
|
||||
// =================================================================================================
|
||||
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
||||
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
||||
// width of 100 characters per line.
|
||||
//
|
||||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the xdot OpenCL kernels. Note that the results are
|
||||
// not verified, since the result is not final and depends on the WGS2 parameter.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgN};
|
||||
settings.default_n = 2*1024*1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int V, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "xdot_"+std::to_string(V);
|
||||
settings.kernel_name = (V==1) ? "Xdot" : "XdotEpilogue";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level1/xdot.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_x = args.n;
|
||||
settings.size_y = args.n;
|
||||
settings.size_temp = args.n; // Worst case
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {0, 1, 5};
|
||||
settings.outputs = {}; // no output checking
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = (V==1) ? std::vector<size_t>{2*64} : std::vector<size_t>{1};
|
||||
settings.global_size_ref = (V==1) ? std::vector<size_t>{2*64*64} : std::vector<size_t>{64};
|
||||
settings.local_size = {1};
|
||||
settings.local_size_ref = {64};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = (V==1) ? TransformVector{{"WGS1"}} : TransformVector{{"WGS2"}};
|
||||
settings.mul_global = (V==1) ? TransformVector{{"WGS1"}} : TransformVector{{"WGS2"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"WGS"+std::to_string(V), {32, 64, 128, 256, 512, 1024}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = (V==1) ? (2*args.n + 1) * GetBytes(args.precision) : 1 * GetBytes(args.precision);
|
||||
settings.performance_unit = (V==1) ? "GB/s" : "N/A";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int V, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
if (V == 1) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.n));
|
||||
kernel.SetArgument(1, buffers[0]()); // 0 == X vector
|
||||
kernel.SetArgument(2, 0);
|
||||
kernel.SetArgument(3, 1);
|
||||
kernel.SetArgument(4, buffers[1]()); // 1 == Y vector
|
||||
kernel.SetArgument(5, 0);
|
||||
kernel.SetArgument(6, 1);
|
||||
kernel.SetArgument(7, buffers[5]()); // 5 == temp; no output checking - size varies
|
||||
kernel.SetArgument(8, static_cast<int>(false));
|
||||
}
|
||||
else {
|
||||
kernel.SetArgument(0, buffers[5]()); // 5 == temp
|
||||
kernel.SetArgument(1, buffers[0]()); // 0 == X vector; no output checking - size varies
|
||||
kernel.SetArgument(2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
|
@ -7,162 +7,11 @@
|
|||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the xgemm OpenCL kernels. There are two variations:
|
||||
// - V==1: This tests some limited set of tuning parameters exhaustively.
|
||||
// - V==2: This tests a much larger set of tuning parameters by randomly sampling a subset.
|
||||
// This file uses the auto-tuner to tune the xgemm OpenCL kernels.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int V) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgK, kArgAlpha, kArgBeta, kArgFraction,
|
||||
kArgHeuristicSelection, kArgPsoSwarmSize,
|
||||
kArgPsoInfGlobal, kArgPsoInfLocal, kArgPsoInfRandom};
|
||||
settings.default_m = 1024;
|
||||
settings.default_n = 1024;
|
||||
settings.default_k = 1024;
|
||||
settings.default_fraction = (V==1) ? 1.0 : 512.0; // test all or sample randomly
|
||||
settings.default_num_runs = 2;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int V, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = (V==1) ? "xgemm_1" : "xgemm_2";
|
||||
settings.kernel_name = "Xgemm";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level3/xgemm_part1.opencl"
|
||||
#include "../src/kernels/level3/xgemm_part2.opencl"
|
||||
#include "../src/kernels/level3/xgemm_part3.opencl"
|
||||
#include "../src/kernels/level3/xgemm_part4.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.m * args.k;
|
||||
settings.size_b = args.n * args.k;
|
||||
settings.size_c = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3, 4};
|
||||
settings.outputs = {4};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"MDIMC", "NDIMC"}};
|
||||
settings.mul_global = {{"MDIMC", "NDIMC"}};
|
||||
settings.div_global = {{"MWG", "NWG"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
if (V==1) { // limited subset of tuning parameters - but explorable exhaustively
|
||||
settings.parameters = {
|
||||
{"MWG", {16, 32, 64}},
|
||||
{"NWG", {16, 32, 64}},
|
||||
{"KWG", {32}},
|
||||
{"MDIMC", {8, 16, 32}},
|
||||
{"NDIMC", {8, 16, 32}},
|
||||
{"MDIMA", {8, 16, 32}},
|
||||
{"NDIMB", {8, 16, 32}},
|
||||
{"KWI", {2}},
|
||||
{"VWM", {1, 2, 4}},
|
||||
{"VWN", {1, 2, 4}},
|
||||
{"STRM", {0}},
|
||||
{"STRN", {0}},
|
||||
{"SA", {0, 1}},
|
||||
{"SB", {0, 1}},
|
||||
};
|
||||
}
|
||||
else { // a lot more tuning parameters - has to be sampled randomly, too much to test all
|
||||
settings.parameters = {
|
||||
{"MWG", {16, 32, 64, 128}},
|
||||
{"NWG", {16, 32, 64, 128}},
|
||||
{"KWG", {16, 32}},
|
||||
{"MDIMC", {8, 16, 32}},
|
||||
{"NDIMC", {8, 16, 32}},
|
||||
{"MDIMA", {8, 16, 32}},
|
||||
{"NDIMB", {8, 16, 32}},
|
||||
{"KWI", {2}},
|
||||
{"VWM", {1, 2, 4, 8}},
|
||||
{"VWN", {1, 2, 4, 8}},
|
||||
{"STRM", {0, 1}},
|
||||
{"STRN", {0, 1}},
|
||||
{"SA", {0, 1}},
|
||||
{"SB", {0, 1}},
|
||||
};
|
||||
}
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 2 * args.m * args.n * args.k;
|
||||
settings.performance_unit = "GFLOPS";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int V) {
|
||||
auto constraints = std::vector<Constraint>();
|
||||
auto MultipleOfX = [] (std::vector<size_t> v) { return IsMultiple(v[0], v[1]); };
|
||||
auto MultipleOfXMulY = [] (std::vector<size_t> v) { return IsMultiple(v[0], v[1]*v[2]); };
|
||||
auto MultipleOfXMulYDivZ = [] (std::vector<size_t> v) { return IsMultiple(v[0], (v[1]*v[2])/v[3]); };
|
||||
// Requirement for unrolling the KWG loop
|
||||
constraints.push_back({MultipleOfX, {"KWG", "KWI"}});
|
||||
// Required for integer MWI and NWI
|
||||
constraints.push_back({MultipleOfXMulY, {"MWG", "MDIMC", "VWM"}});
|
||||
constraints.push_back({MultipleOfXMulY, {"NWG", "NDIMC", "VWN"}});
|
||||
// Required for integer MWIA and NWIB
|
||||
constraints.push_back({MultipleOfXMulY, {"MWG", "MDIMA", "VWM"}});
|
||||
constraints.push_back({MultipleOfXMulY, {"NWG", "NDIMB", "VWN"}});
|
||||
// KWG has to be a multiple of KDIMA = ((MDIMC*NDIMC)/(MDIMA)) and KDIMB = (...)
|
||||
constraints.push_back({MultipleOfXMulYDivZ, {"KWG", "MDIMC", "NDIMC", "MDIMA"}});
|
||||
constraints.push_back({MultipleOfXMulYDivZ, {"KWG", "MDIMC", "NDIMC", "NDIMB"}});
|
||||
|
||||
// Extra constraints for variation 1 to limit the set of options significantly
|
||||
if (V==1) {
|
||||
auto IsEqual = [] (std::vector<size_t> v) { return v[0] == v[1]; };
|
||||
constraints.push_back({IsEqual, {"MDIMC", "MDIMA"}});
|
||||
constraints.push_back({IsEqual, {"NDIMC", "NDIMB"}});
|
||||
constraints.push_back({IsEqual, {"SA", "SB"}});
|
||||
}
|
||||
return constraints;
|
||||
}
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, static_cast<int>(args.n));
|
||||
kernel.SetArgument(2, static_cast<int>(args.k));
|
||||
kernel.SetArgument(3, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(4, GetRealArg(args.beta));
|
||||
kernel.SetArgument(5, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(6, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(7, buffers[4]()); // 4 == C matrix
|
||||
kernel.SetArgument(8, 0);
|
||||
kernel.SetArgument(9, 0);
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
#include "tuning/kernels/xgemm.hpp"
|
||||
|
||||
// Shortcuts to the clblast namespace
|
||||
using half = clblast::half;
|
||||
|
|
|
@ -0,0 +1,165 @@
|
|||
|
||||
// =================================================================================================
|
||||
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
||||
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
||||
// width of 100 characters per line.
|
||||
//
|
||||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the xgemm OpenCL kernels. There are two variations:
|
||||
// - V==1: This tests some limited set of tuning parameters exhaustively.
|
||||
// - V==2: This tests a much larger set of tuning parameters by randomly sampling a subset.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int V) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgK, kArgAlpha, kArgBeta, kArgFraction,
|
||||
kArgHeuristicSelection, kArgPsoSwarmSize,
|
||||
kArgPsoInfGlobal, kArgPsoInfLocal, kArgPsoInfRandom};
|
||||
settings.default_m = 1024;
|
||||
settings.default_n = 1024;
|
||||
settings.default_k = 1024;
|
||||
settings.default_fraction = (V==1) ? 1.0 : 512.0; // test all or sample randomly
|
||||
settings.default_num_runs = 2;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int V, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = (V==1) ? "xgemm_1" : "xgemm_2";
|
||||
settings.kernel_name = "Xgemm";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level3/xgemm_part1.opencl"
|
||||
#include "../src/kernels/level3/xgemm_part2.opencl"
|
||||
#include "../src/kernels/level3/xgemm_part3.opencl"
|
||||
#include "../src/kernels/level3/xgemm_part4.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.m * args.k;
|
||||
settings.size_b = args.n * args.k;
|
||||
settings.size_c = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3, 4};
|
||||
settings.outputs = {4};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"MDIMC", "NDIMC"}};
|
||||
settings.mul_global = {{"MDIMC", "NDIMC"}};
|
||||
settings.div_global = {{"MWG", "NWG"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
if (V==1) { // limited subset of tuning parameters - but explorable exhaustively
|
||||
settings.parameters = {
|
||||
{"MWG", {16, 32, 64}},
|
||||
{"NWG", {16, 32, 64}},
|
||||
{"KWG", {32}},
|
||||
{"MDIMC", {8, 16, 32}},
|
||||
{"NDIMC", {8, 16, 32}},
|
||||
{"MDIMA", {8, 16, 32}},
|
||||
{"NDIMB", {8, 16, 32}},
|
||||
{"KWI", {2}},
|
||||
{"VWM", {1, 2, 4}},
|
||||
{"VWN", {1, 2, 4}},
|
||||
{"STRM", {0}},
|
||||
{"STRN", {0}},
|
||||
{"SA", {0, 1}},
|
||||
{"SB", {0, 1}},
|
||||
};
|
||||
}
|
||||
else { // a lot more tuning parameters - has to be sampled randomly, too much to test all
|
||||
settings.parameters = {
|
||||
{"MWG", {16, 32, 64, 128}},
|
||||
{"NWG", {16, 32, 64, 128}},
|
||||
{"KWG", {16, 32}},
|
||||
{"MDIMC", {8, 16, 32}},
|
||||
{"NDIMC", {8, 16, 32}},
|
||||
{"MDIMA", {8, 16, 32}},
|
||||
{"NDIMB", {8, 16, 32}},
|
||||
{"KWI", {2}},
|
||||
{"VWM", {1, 2, 4, 8}},
|
||||
{"VWN", {1, 2, 4, 8}},
|
||||
{"STRM", {0, 1}},
|
||||
{"STRN", {0, 1}},
|
||||
{"SA", {0, 1}},
|
||||
{"SB", {0, 1}},
|
||||
};
|
||||
}
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 2 * args.m * args.n * args.k;
|
||||
settings.performance_unit = "GFLOPS";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int V) {
|
||||
auto constraints = std::vector<Constraint>();
|
||||
auto MultipleOfX = [] (std::vector<size_t> v) { return IsMultiple(v[0], v[1]); };
|
||||
auto MultipleOfXMulY = [] (std::vector<size_t> v) { return IsMultiple(v[0], v[1]*v[2]); };
|
||||
auto MultipleOfXMulYDivZ = [] (std::vector<size_t> v) { return IsMultiple(v[0], (v[1]*v[2])/v[3]); };
|
||||
// Requirement for unrolling the KWG loop
|
||||
constraints.push_back({MultipleOfX, {"KWG", "KWI"}});
|
||||
// Required for integer MWI and NWI
|
||||
constraints.push_back({MultipleOfXMulY, {"MWG", "MDIMC", "VWM"}});
|
||||
constraints.push_back({MultipleOfXMulY, {"NWG", "NDIMC", "VWN"}});
|
||||
// Required for integer MWIA and NWIB
|
||||
constraints.push_back({MultipleOfXMulY, {"MWG", "MDIMA", "VWM"}});
|
||||
constraints.push_back({MultipleOfXMulY, {"NWG", "NDIMB", "VWN"}});
|
||||
// KWG has to be a multiple of KDIMA = ((MDIMC*NDIMC)/(MDIMA)) and KDIMB = (...)
|
||||
constraints.push_back({MultipleOfXMulYDivZ, {"KWG", "MDIMC", "NDIMC", "MDIMA"}});
|
||||
constraints.push_back({MultipleOfXMulYDivZ, {"KWG", "MDIMC", "NDIMC", "NDIMB"}});
|
||||
|
||||
// Extra constraints for variation 1 to limit the set of options significantly
|
||||
if (V==1) {
|
||||
auto IsEqual = [] (std::vector<size_t> v) { return v[0] == v[1]; };
|
||||
constraints.push_back({IsEqual, {"MDIMC", "MDIMA"}});
|
||||
constraints.push_back({IsEqual, {"NDIMC", "NDIMB"}});
|
||||
constraints.push_back({IsEqual, {"SA", "SB"}});
|
||||
}
|
||||
return constraints;
|
||||
}
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, static_cast<int>(args.n));
|
||||
kernel.SetArgument(2, static_cast<int>(args.k));
|
||||
kernel.SetArgument(3, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(4, GetRealArg(args.beta));
|
||||
kernel.SetArgument(5, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(6, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(7, buffers[4]()); // 4 == C matrix
|
||||
kernel.SetArgument(8, 0);
|
||||
kernel.SetArgument(9, 0);
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
|
@ -7,159 +7,11 @@
|
|||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the direct xgemm kernels. There are two variations:
|
||||
// - V==1: This tests some limited set of tuning parameters exhaustively.
|
||||
// - V==2: This tests a much larger set of tuning parameters by randomly sampling a subset.
|
||||
// This file uses the auto-tuner to tune the direct xgemm kernels.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int V) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgK, kArgAlpha, kArgBeta, kArgFraction,
|
||||
kArgHeuristicSelection, kArgPsoSwarmSize,
|
||||
kArgPsoInfGlobal, kArgPsoInfLocal, kArgPsoInfRandom};
|
||||
settings.default_m = 256;
|
||||
settings.default_n = 256;
|
||||
settings.default_k = 256;
|
||||
settings.default_fraction = (V==1) ? 1.0 : 64.0; // test all or sample randomly
|
||||
settings.default_num_runs = 4;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int V, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = (V==1) ? "xgemm_direct_1" : "xgemm_direct_2";
|
||||
settings.kernel_name = "XgemmDirectTN";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level3/xgemm_direct_part1.opencl"
|
||||
#include "../src/kernels/level3/xgemm_direct_part2.opencl"
|
||||
#include "../src/kernels/level3/xgemm_direct_part3.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.m * args.k;
|
||||
settings.size_b = args.n * args.k;
|
||||
settings.size_c = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3, 4};
|
||||
settings.outputs = {4};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"MDIMCD", "NDIMCD"}};
|
||||
settings.mul_global = {{"MDIMCD", "NDIMCD"}};
|
||||
settings.div_global = {{"WGD", "WGD"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
if (V==1) { // limited subset of tuning parameters - but explorable exhaustively
|
||||
settings.parameters = {
|
||||
{"WGD", {8, 16, 32}},
|
||||
{"MDIMCD", {8, 16, 32}},
|
||||
{"NDIMCD", {8, 16, 32}},
|
||||
{"MDIMAD", {8, 16, 32}},
|
||||
{"NDIMBD", {8, 16, 32}},
|
||||
{"KWID", {2}},
|
||||
{"VWMD", {1, 2, 4, 8}},
|
||||
{"VWND", {1, 2, 4, 8}},
|
||||
{"PADA", {1}},
|
||||
{"PADB", {1}},
|
||||
};
|
||||
}
|
||||
else { // a lot more tuning parameters - has to be sampled randomly, too much to test all
|
||||
settings.parameters = {
|
||||
{"WGD", {8, 16, 32, 64}},
|
||||
{"MDIMCD", {8, 16, 32}},
|
||||
{"NDIMCD", {8, 16, 32}},
|
||||
{"MDIMAD", {8, 16, 32}},
|
||||
{"NDIMBD", {8, 16, 32}},
|
||||
{"KWID", {2, 8, 16}},
|
||||
{"VWMD", {1, 2, 4, 8}},
|
||||
{"VWND", {1, 2, 4, 8}},
|
||||
{"PADA", {0, 1}},
|
||||
{"PADB", {0, 1}},
|
||||
};
|
||||
}
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 2 * args.m * args.n * args.k;
|
||||
settings.performance_unit = "GFLOPS";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int V) {
|
||||
auto constraints = std::vector<Constraint>();
|
||||
auto MultipleOfX = [] (std::vector<size_t> v) { return IsMultiple(v[0], v[1]); };
|
||||
auto MultipleOfXMulY = [] (std::vector<size_t> v) { return IsMultiple(v[0], v[1]*v[2]); };
|
||||
auto MultipleOfXMulYDivZ = [] (std::vector<size_t> v) { return IsMultiple(v[0], (v[1]*v[2])/v[3]); };
|
||||
// Requirement for unrolling the WGD loop
|
||||
constraints.push_back({MultipleOfX, {"WGD", "KWID"}});
|
||||
// Required for integer MWID and NWID
|
||||
constraints.push_back({MultipleOfXMulY, {"WGD", "MDIMCD", "VWMD"}});
|
||||
constraints.push_back({MultipleOfXMulY, {"WGD", "NDIMCD", "VWND"}});
|
||||
// Required for integer MWIAD and NWIBD
|
||||
constraints.push_back({MultipleOfXMulY, {"WGD", "MDIMAD", "VWMD"}});
|
||||
constraints.push_back({MultipleOfXMulY, {"WGD", "NDIMBD", "VWND"}});
|
||||
// WGD has to be a multiple of KDIMAD = ((MDIMCD*NDIMCD)/(MDIMAD)) and KDIMBD = (...)
|
||||
constraints.push_back({MultipleOfXMulYDivZ, {"WGD", "MDIMCD", "NDIMCD", "MDIMAD"}});
|
||||
constraints.push_back({MultipleOfXMulYDivZ, {"WGD", "MDIMCD", "NDIMCD", "NDIMBD"}});
|
||||
|
||||
// Extra constraints for variation 1 to limit the set of options significantly
|
||||
if (V==1) {
|
||||
auto IsEqual = [] (std::vector<size_t> v) { return v[0] == v[1]; };
|
||||
constraints.push_back({IsEqual, {"MDIMCD", "MDIMAD"}});
|
||||
constraints.push_back({IsEqual, {"NDIMCD", "NDIMBD"}});
|
||||
}
|
||||
return constraints;
|
||||
}
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, static_cast<int>(args.n));
|
||||
kernel.SetArgument(2, static_cast<int>(args.k));
|
||||
kernel.SetArgument(3, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(4, GetRealArg(args.beta));
|
||||
kernel.SetArgument(5, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(6, 0); // a_offset
|
||||
kernel.SetArgument(7, static_cast<int>(args.k)); // a_ld
|
||||
kernel.SetArgument(8, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(9, 0); // b_offset
|
||||
kernel.SetArgument(10, static_cast<int>(args.n)); // b_ld
|
||||
kernel.SetArgument(11, buffers[4]()); // 4 == C matrix
|
||||
kernel.SetArgument(12, 0); // c_offset
|
||||
kernel.SetArgument(13, static_cast<int>(args.n)); // c_ld
|
||||
kernel.SetArgument(14, 1); // c_do_transpose
|
||||
kernel.SetArgument(15, 0); // a_conjugate
|
||||
kernel.SetArgument(16, 0); // b_conjugate
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
#include "tuning/kernels/xgemm_direct.hpp"
|
||||
|
||||
// Shortcuts to the clblast namespace
|
||||
using half = clblast::half;
|
||||
|
|
|
@ -0,0 +1,162 @@
|
|||
|
||||
// =================================================================================================
|
||||
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
||||
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
||||
// width of 100 characters per line.
|
||||
//
|
||||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the direct xgemm kernels. There are two variations:
|
||||
// - V==1: This tests some limited set of tuning parameters exhaustively.
|
||||
// - V==2: This tests a much larger set of tuning parameters by randomly sampling a subset.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int V) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgK, kArgAlpha, kArgBeta, kArgFraction,
|
||||
kArgHeuristicSelection, kArgPsoSwarmSize,
|
||||
kArgPsoInfGlobal, kArgPsoInfLocal, kArgPsoInfRandom};
|
||||
settings.default_m = 256;
|
||||
settings.default_n = 256;
|
||||
settings.default_k = 256;
|
||||
settings.default_fraction = (V==1) ? 1.0 : 64.0; // test all or sample randomly
|
||||
settings.default_num_runs = 4;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int V, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = (V==1) ? "xgemm_direct_1" : "xgemm_direct_2";
|
||||
settings.kernel_name = "XgemmDirectTN";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level3/xgemm_direct_part1.opencl"
|
||||
#include "../src/kernels/level3/xgemm_direct_part2.opencl"
|
||||
#include "../src/kernels/level3/xgemm_direct_part3.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_a = args.m * args.k;
|
||||
settings.size_b = args.n * args.k;
|
||||
settings.size_c = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {2, 3, 4};
|
||||
settings.outputs = {4};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"MDIMCD", "NDIMCD"}};
|
||||
settings.mul_global = {{"MDIMCD", "NDIMCD"}};
|
||||
settings.div_global = {{"WGD", "WGD"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
if (V==1) { // limited subset of tuning parameters - but explorable exhaustively
|
||||
settings.parameters = {
|
||||
{"WGD", {8, 16, 32}},
|
||||
{"MDIMCD", {8, 16, 32}},
|
||||
{"NDIMCD", {8, 16, 32}},
|
||||
{"MDIMAD", {8, 16, 32}},
|
||||
{"NDIMBD", {8, 16, 32}},
|
||||
{"KWID", {2}},
|
||||
{"VWMD", {1, 2, 4, 8}},
|
||||
{"VWND", {1, 2, 4, 8}},
|
||||
{"PADA", {1}},
|
||||
{"PADB", {1}},
|
||||
};
|
||||
}
|
||||
else { // a lot more tuning parameters - has to be sampled randomly, too much to test all
|
||||
settings.parameters = {
|
||||
{"WGD", {8, 16, 32, 64}},
|
||||
{"MDIMCD", {8, 16, 32}},
|
||||
{"NDIMCD", {8, 16, 32}},
|
||||
{"MDIMAD", {8, 16, 32}},
|
||||
{"NDIMBD", {8, 16, 32}},
|
||||
{"KWID", {2, 8, 16}},
|
||||
{"VWMD", {1, 2, 4, 8}},
|
||||
{"VWND", {1, 2, 4, 8}},
|
||||
{"PADA", {0, 1}},
|
||||
{"PADB", {0, 1}},
|
||||
};
|
||||
}
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = 2 * args.m * args.n * args.k;
|
||||
settings.performance_unit = "GFLOPS";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int V) {
|
||||
auto constraints = std::vector<Constraint>();
|
||||
auto MultipleOfX = [] (std::vector<size_t> v) { return IsMultiple(v[0], v[1]); };
|
||||
auto MultipleOfXMulY = [] (std::vector<size_t> v) { return IsMultiple(v[0], v[1]*v[2]); };
|
||||
auto MultipleOfXMulYDivZ = [] (std::vector<size_t> v) { return IsMultiple(v[0], (v[1]*v[2])/v[3]); };
|
||||
// Requirement for unrolling the WGD loop
|
||||
constraints.push_back({MultipleOfX, {"WGD", "KWID"}});
|
||||
// Required for integer MWID and NWID
|
||||
constraints.push_back({MultipleOfXMulY, {"WGD", "MDIMCD", "VWMD"}});
|
||||
constraints.push_back({MultipleOfXMulY, {"WGD", "NDIMCD", "VWND"}});
|
||||
// Required for integer MWIAD and NWIBD
|
||||
constraints.push_back({MultipleOfXMulY, {"WGD", "MDIMAD", "VWMD"}});
|
||||
constraints.push_back({MultipleOfXMulY, {"WGD", "NDIMBD", "VWND"}});
|
||||
// WGD has to be a multiple of KDIMAD = ((MDIMCD*NDIMCD)/(MDIMAD)) and KDIMBD = (...)
|
||||
constraints.push_back({MultipleOfXMulYDivZ, {"WGD", "MDIMCD", "NDIMCD", "MDIMAD"}});
|
||||
constraints.push_back({MultipleOfXMulYDivZ, {"WGD", "MDIMCD", "NDIMCD", "NDIMBD"}});
|
||||
|
||||
// Extra constraints for variation 1 to limit the set of options significantly
|
||||
if (V==1) {
|
||||
auto IsEqual = [] (std::vector<size_t> v) { return v[0] == v[1]; };
|
||||
constraints.push_back({IsEqual, {"MDIMCD", "MDIMAD"}});
|
||||
constraints.push_back({IsEqual, {"NDIMCD", "NDIMBD"}});
|
||||
}
|
||||
return constraints;
|
||||
}
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, static_cast<int>(args.n));
|
||||
kernel.SetArgument(2, static_cast<int>(args.k));
|
||||
kernel.SetArgument(3, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(4, GetRealArg(args.beta));
|
||||
kernel.SetArgument(5, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(6, 0); // a_offset
|
||||
kernel.SetArgument(7, static_cast<int>(args.k)); // a_ld
|
||||
kernel.SetArgument(8, buffers[3]()); // 3 == B matrix
|
||||
kernel.SetArgument(9, 0); // b_offset
|
||||
kernel.SetArgument(10, static_cast<int>(args.n)); // b_ld
|
||||
kernel.SetArgument(11, buffers[4]()); // 4 == C matrix
|
||||
kernel.SetArgument(12, 0); // c_offset
|
||||
kernel.SetArgument(13, static_cast<int>(args.n)); // c_ld
|
||||
kernel.SetArgument(14, 1); // c_do_transpose
|
||||
kernel.SetArgument(15, 0); // a_conjugate
|
||||
kernel.SetArgument(16, 0); // b_conjugate
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
|
@ -7,135 +7,11 @@
|
|||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the xgemv OpenCL kernels. Three variants are tuned:
|
||||
// 1: The full version of the kernel
|
||||
// 2: The fast version for non-transposed matrices
|
||||
// 3: The fast version for transposed matrices
|
||||
// This file uses the auto-tuner to tune the xgemv OpenCL kernels.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgAlpha, kArgBeta};
|
||||
settings.default_m = 2048;
|
||||
settings.default_n = 2048;
|
||||
settings.default_num_runs = 4;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int V, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = (V==1) ? "xgemv" : ((V==2) ? "xgemv_fast" : "xgemv_fast_rot");
|
||||
settings.kernel_name = (V==1) ? "Xgemv" : ((V==2) ? "XgemvFast" : "XgemvFastRot");
|
||||
settings.sources =
|
||||
#include "../src/kernels/level2/xgemv.opencl"
|
||||
#include "../src/kernels/level2/xgemv_fast.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_x = args.n;
|
||||
settings.size_y = args.m;
|
||||
settings.size_a = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {0, 1, 2};
|
||||
settings.outputs = {1};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1};
|
||||
settings.local_size_ref = {64};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"WGS"+std::to_string(V)}};
|
||||
settings.div_global = (V==1 || V==2) ? TransformVector{{"WPT"+std::to_string(V)}} : TransformVector{};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
if (V==1) {
|
||||
settings.parameters = {
|
||||
{"WGS"+std::to_string(V), {32, 64, 128, 256}},
|
||||
{"WPT"+std::to_string(V), {1, 2, 4}},
|
||||
};
|
||||
}
|
||||
if (V==2) {
|
||||
settings.parameters = {
|
||||
{"WGS"+std::to_string(V), {16, 32, 64, 128, 256}},
|
||||
{"WPT"+std::to_string(V), {1, 2, 4}},
|
||||
{"VW"+std::to_string(V), {1, 2, 4, 8}},
|
||||
};
|
||||
}
|
||||
if (V==3) {
|
||||
settings.parameters = {
|
||||
{"WGS"+std::to_string(V), {16, 32, 64, 128}},
|
||||
{"WPT"+std::to_string(V), {1, 2, 4, 8, 16, 32}},
|
||||
{"VW"+std::to_string(V), {1, 2, 4, 8}},
|
||||
};
|
||||
}
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = (args.m*args.n + 2*args.m + args.n) * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int V) {
|
||||
auto constraints = std::vector<Constraint>();
|
||||
if (V==2 || V==3) {
|
||||
auto MultipleOfX = [] (std::vector<size_t> v) { return IsMultiple(v[0], v[1]); };
|
||||
constraints.push_back({MultipleOfX, {"WPT"+std::to_string(V), "VW"+std::to_string(V)}});
|
||||
}
|
||||
if (V==3) {
|
||||
auto LargerOrEqual = [] (std::vector<size_t> v) { return v[0] >= v[1]; };
|
||||
constraints.push_back({LargerOrEqual, {"WGS"+std::to_string(V), "WPT"+std::to_string(V)}});
|
||||
}
|
||||
return constraints;
|
||||
}
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int V, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
auto a_rotated = (V==3) ? 1 : 0;
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, static_cast<int>(args.n));
|
||||
kernel.SetArgument(2, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(3, GetRealArg(args.beta));
|
||||
kernel.SetArgument(4, a_rotated);
|
||||
kernel.SetArgument(5, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(6, 0);
|
||||
kernel.SetArgument(7, static_cast<int>(args.m));
|
||||
kernel.SetArgument(8, buffers[0]()); // 0 == X vector
|
||||
kernel.SetArgument(9, 0);
|
||||
kernel.SetArgument(10, 1);
|
||||
kernel.SetArgument(11, buffers[1]()); // 1 == Y vector
|
||||
kernel.SetArgument(12, 0);
|
||||
kernel.SetArgument(13, 1);
|
||||
kernel.SetArgument(14, 0); // Conjugate transpose
|
||||
kernel.SetArgument(15, 0); // Additional parameter
|
||||
kernel.SetArgument(16, 0); // Banded 'kl'
|
||||
kernel.SetArgument(17, 0); // Banded 'ku'
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
#include "tuning/kernels/xgemv.hpp"
|
||||
|
||||
// Shortcuts to the clblast namespace
|
||||
using half = clblast::half;
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
|
||||
// =================================================================================================
|
||||
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
||||
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
||||
// width of 100 characters per line.
|
||||
//
|
||||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the xgemv OpenCL kernels. Three variants are tuned:
|
||||
// 1: The full version of the kernel
|
||||
// 2: The fast version for non-transposed matrices
|
||||
// 3: The fast version for transposed matrices
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgAlpha, kArgBeta};
|
||||
settings.default_m = 2048;
|
||||
settings.default_n = 2048;
|
||||
settings.default_num_runs = 4;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int V, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = (V==1) ? "xgemv" : ((V==2) ? "xgemv_fast" : "xgemv_fast_rot");
|
||||
settings.kernel_name = (V==1) ? "Xgemv" : ((V==2) ? "XgemvFast" : "XgemvFastRot");
|
||||
settings.sources =
|
||||
#include "../src/kernels/level2/xgemv.opencl"
|
||||
#include "../src/kernels/level2/xgemv_fast.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_x = args.n;
|
||||
settings.size_y = args.m;
|
||||
settings.size_a = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {0, 1, 2};
|
||||
settings.outputs = {1};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1};
|
||||
settings.local_size_ref = {64};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"WGS"+std::to_string(V)}};
|
||||
settings.div_global = (V==1 || V==2) ? TransformVector{{"WPT"+std::to_string(V)}} : TransformVector{};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
if (V==1) {
|
||||
settings.parameters = {
|
||||
{"WGS"+std::to_string(V), {32, 64, 128, 256}},
|
||||
{"WPT"+std::to_string(V), {1, 2, 4}},
|
||||
};
|
||||
}
|
||||
if (V==2) {
|
||||
settings.parameters = {
|
||||
{"WGS"+std::to_string(V), {16, 32, 64, 128, 256}},
|
||||
{"WPT"+std::to_string(V), {1, 2, 4}},
|
||||
{"VW"+std::to_string(V), {1, 2, 4, 8}},
|
||||
};
|
||||
}
|
||||
if (V==3) {
|
||||
settings.parameters = {
|
||||
{"WGS"+std::to_string(V), {16, 32, 64, 128}},
|
||||
{"WPT"+std::to_string(V), {1, 2, 4, 8, 16, 32}},
|
||||
{"VW"+std::to_string(V), {1, 2, 4, 8}},
|
||||
};
|
||||
}
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = (args.m*args.n + 2*args.m + args.n) * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int V) {
|
||||
auto constraints = std::vector<Constraint>();
|
||||
if (V==2 || V==3) {
|
||||
auto MultipleOfX = [] (std::vector<size_t> v) { return IsMultiple(v[0], v[1]); };
|
||||
constraints.push_back({MultipleOfX, {"WPT"+std::to_string(V), "VW"+std::to_string(V)}});
|
||||
}
|
||||
if (V==3) {
|
||||
auto LargerOrEqual = [] (std::vector<size_t> v) { return v[0] >= v[1]; };
|
||||
constraints.push_back({LargerOrEqual, {"WGS"+std::to_string(V), "WPT"+std::to_string(V)}});
|
||||
}
|
||||
return constraints;
|
||||
}
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int V, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
auto a_rotated = (V==3) ? 1 : 0;
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, static_cast<int>(args.n));
|
||||
kernel.SetArgument(2, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(3, GetRealArg(args.beta));
|
||||
kernel.SetArgument(4, a_rotated);
|
||||
kernel.SetArgument(5, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(6, 0);
|
||||
kernel.SetArgument(7, static_cast<int>(args.m));
|
||||
kernel.SetArgument(8, buffers[0]()); // 0 == X vector
|
||||
kernel.SetArgument(9, 0);
|
||||
kernel.SetArgument(10, 1);
|
||||
kernel.SetArgument(11, buffers[1]()); // 1 == Y vector
|
||||
kernel.SetArgument(12, 0);
|
||||
kernel.SetArgument(13, 1);
|
||||
kernel.SetArgument(14, 0); // Conjugate transpose
|
||||
kernel.SetArgument(15, 0); // Additional parameter
|
||||
kernel.SetArgument(16, 0); // Banded 'kl'
|
||||
kernel.SetArgument(17, 0); // Banded 'ku'
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
|
@ -11,95 +11,7 @@
|
|||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgAlpha};
|
||||
settings.default_m = 1024;
|
||||
settings.default_n = 1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "xger";
|
||||
settings.kernel_name = "Xger";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level2/level2.opencl"
|
||||
#include "../src/kernels/level2/xger.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_x = args.m;
|
||||
settings.size_y = args.n;
|
||||
settings.size_a = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {0, 1, 2};
|
||||
settings.outputs = {2};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"WGS1", "WGS2"}};
|
||||
settings.div_global = {{"WPT", "WPT"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"WGS1", {4, 8, 16, 32, 64, 128, 256, 512}},
|
||||
{"WGS2", {1, 2, 4, 8, 16, 32, 64, 128, 256}},
|
||||
{"WPT", {1, 2, 4}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = (2*args.m*args.n + args.m + args.n) * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, static_cast<int>(args.n));
|
||||
kernel.SetArgument(2, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(3, buffers[0]()); // 0 == X vector
|
||||
kernel.SetArgument(4, 0); // x_offset
|
||||
kernel.SetArgument(5, 1); // x_increment
|
||||
kernel.SetArgument(6, buffers[1]()); // 1 == Y vector
|
||||
kernel.SetArgument(7, 0); // y_offset
|
||||
kernel.SetArgument(8, 1); // y_increment
|
||||
kernel.SetArgument(9, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(10, 0); // a_offset
|
||||
kernel.SetArgument(11, static_cast<int>(args.m)); // a_ld
|
||||
kernel.SetArgument(12, 0); // a_is_rowmajor
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
#include "tuning/kernels/xger.hpp"
|
||||
|
||||
// Shortcuts to the clblast namespace
|
||||
using half = clblast::half;
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
|
||||
// =================================================================================================
|
||||
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
||||
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
||||
// width of 100 characters per line.
|
||||
//
|
||||
// Author(s):
|
||||
// Cedric Nugteren <www.cedricnugteren.nl>
|
||||
//
|
||||
// This file uses the auto-tuner to tune the xger OpenCL kernels.
|
||||
//
|
||||
// =================================================================================================
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
#include "tuning/tuning.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Settings for this kernel (default command-line arguments)
|
||||
TunerDefaults GetTunerDefaults(const int) {
|
||||
auto settings = TunerDefaults();
|
||||
settings.options = {kArgM, kArgN, kArgAlpha};
|
||||
settings.default_m = 1024;
|
||||
settings.default_n = 1024;
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Settings for this kernel (general)
|
||||
template <typename T>
|
||||
TunerSettings GetTunerSettings(const int, const Arguments<T> &args) {
|
||||
auto settings = TunerSettings();
|
||||
|
||||
// Identification of the kernel
|
||||
settings.kernel_family = "xger";
|
||||
settings.kernel_name = "Xger";
|
||||
settings.sources =
|
||||
#include "../src/kernels/level2/level2.opencl"
|
||||
#include "../src/kernels/level2/xger.opencl"
|
||||
;
|
||||
|
||||
// Buffer sizes
|
||||
settings.size_x = args.m;
|
||||
settings.size_y = args.n;
|
||||
settings.size_a = args.m * args.n;
|
||||
|
||||
// Inputs and outputs IDs (X:0, Y:1, A:2, B:3, C:4, temp:5)
|
||||
settings.inputs = {0, 1, 2};
|
||||
settings.outputs = {2};
|
||||
|
||||
// Sets the base thread configuration
|
||||
settings.global_size = {args.m, args.n};
|
||||
settings.global_size_ref = settings.global_size;
|
||||
settings.local_size = {1, 1};
|
||||
settings.local_size_ref = {8, 8};
|
||||
|
||||
// Transforms the thread configuration based on the parameters
|
||||
settings.mul_local = {{"WGS1", "WGS2"}};
|
||||
settings.div_global = {{"WPT", "WPT"}};
|
||||
|
||||
// Sets the tuning parameters and their possible values
|
||||
settings.parameters = {
|
||||
{"WGS1", {4, 8, 16, 32, 64, 128, 256, 512}},
|
||||
{"WGS2", {1, 2, 4, 8, 16, 32, 64, 128, 256}},
|
||||
{"WPT", {1, 2, 4}},
|
||||
};
|
||||
|
||||
// Describes how to compute the performance metrics
|
||||
settings.metric_amount = (2*args.m*args.n + args.m + args.n) * GetBytes(args.precision);
|
||||
settings.performance_unit = "GB/s";
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
// Tests for valid arguments
|
||||
template <typename T>
|
||||
void TestValidArguments(const int, const Arguments<T> &) { }
|
||||
std::vector<Constraint> SetConstraints(const int) { return {}; }
|
||||
|
||||
// Sets the kernel's arguments
|
||||
template <typename T>
|
||||
void SetArguments(const int, Kernel &kernel, const Arguments<T> &args, std::vector<Buffer<T>>& buffers) {
|
||||
kernel.SetArgument(0, static_cast<int>(args.m));
|
||||
kernel.SetArgument(1, static_cast<int>(args.n));
|
||||
kernel.SetArgument(2, GetRealArg(args.alpha));
|
||||
kernel.SetArgument(3, buffers[0]()); // 0 == X vector
|
||||
kernel.SetArgument(4, 0); // x_offset
|
||||
kernel.SetArgument(5, 1); // x_increment
|
||||
kernel.SetArgument(6, buffers[1]()); // 1 == Y vector
|
||||
kernel.SetArgument(7, 0); // y_offset
|
||||
kernel.SetArgument(8, 1); // y_increment
|
||||
kernel.SetArgument(9, buffers[2]()); // 2 == A matrix
|
||||
kernel.SetArgument(10, 0); // a_offset
|
||||
kernel.SetArgument(11, static_cast<int>(args.m)); // a_ld
|
||||
kernel.SetArgument(12, 0); // a_is_rowmajor
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
|
||||
// Shortcuts to the clblast namespace
|
||||
using half = clblast::half;
|
||||
using float2 = clblast::float2;
|
||||
using double2 = clblast::double2;
|
||||
|
||||
// Main function (not within the clblast namespace)
|
||||
int main(int argc, char *argv[]) {
|
||||
const auto command_line_args = clblast::RetrieveCommandLineArguments(argc, argv);
|
||||
switch(clblast::GetPrecision(command_line_args)) {
|
||||
case clblast::Precision::kHalf: clblast::Tuner<half>(argc, argv, 0, clblast::GetTunerDefaults, clblast::GetTunerSettings<half>, clblast::TestValidArguments<half>, clblast::SetConstraints, clblast::SetArguments<half>); break;
|
||||
case clblast::Precision::kSingle: clblast::Tuner<float>(argc, argv, 0, clblast::GetTunerDefaults, clblast::GetTunerSettings<float>, clblast::TestValidArguments<float>, clblast::SetConstraints, clblast::SetArguments<float>); break;
|
||||
case clblast::Precision::kDouble: clblast::Tuner<double>(argc, argv, 0, clblast::GetTunerDefaults, clblast::GetTunerSettings<double>, clblast::TestValidArguments<double>, clblast::SetConstraints, clblast::SetArguments<double>); break;
|
||||
case clblast::Precision::kComplexSingle: clblast::Tuner<float2>(argc, argv, 0, clblast::GetTunerDefaults, clblast::GetTunerSettings<float2>, clblast::TestValidArguments<float2>, clblast::SetConstraints, clblast::SetArguments<float2>); break;
|
||||
case clblast::Precision::kComplexDouble: clblast::Tuner<double2>(argc, argv, 0, clblast::GetTunerDefaults, clblast::GetTunerSettings<double2>, clblast::TestValidArguments<double2>, clblast::SetConstraints, clblast::SetArguments<double2>); break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// =================================================================================================
|
Loading…
Reference in New Issue