mirror of
https://github.com/CNugteren/CLBlast.git
synced 2024-08-21 20:42:28 +02:00
commit
5e7d140d59
148
src/cache.cpp
148
src/cache.cpp
|
@ -15,108 +15,84 @@
|
|||
#include <vector>
|
||||
#include <mutex>
|
||||
|
||||
#include "database/database.hpp"
|
||||
#include "cache.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// Stores the compiled binary or IR in the cache
|
||||
void StoreBinaryToCache(const std::string &binary, const std::string &device_name,
|
||||
const Precision &precision, const std::string &routine_name) {
|
||||
#ifdef VERBOSE
|
||||
printf("[DEBUG] Storing binary in cache\n");
|
||||
#endif
|
||||
binary_cache_mutex_.lock();
|
||||
binary_cache_.push_back(BinaryCache{binary, device_name, precision, routine_name});
|
||||
binary_cache_mutex_.unlock();
|
||||
template <typename Key, typename Value>
|
||||
template <typename U>
|
||||
Value Cache<Key, Value>::Get(const U &key, bool *in_cache) const {
|
||||
std::lock_guard<std::mutex> lock(cache_mutex_);
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
// generalized std::map::find() of C++14
|
||||
auto it = cache_.find(key);
|
||||
#else
|
||||
// O(n) lookup in a vector
|
||||
auto it = std::find_if(cache_.begin(), cache_.end(), [&] (const std::pair<Key, Value> &pair) {
|
||||
return pair.first == key;
|
||||
});
|
||||
#endif
|
||||
if (it == cache_.end()) {
|
||||
if (in_cache) {
|
||||
*in_cache = false;
|
||||
}
|
||||
return Value();
|
||||
}
|
||||
|
||||
if (in_cache) {
|
||||
*in_cache = true;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
// Stores the compiled program in the cache
|
||||
void StoreProgramToCache(const Program &program, const Context &context,
|
||||
const Precision &precision, const std::string &routine_name) {
|
||||
#ifdef VERBOSE
|
||||
printf("[DEBUG] Storing program in cache\n");
|
||||
#endif
|
||||
program_cache_mutex_.lock();
|
||||
program_cache_.push_back(ProgramCache{program, context(), precision, routine_name});
|
||||
program_cache_mutex_.unlock();
|
||||
template <typename Key, typename Value>
|
||||
void Cache<Key, Value>::Store(Key &&key, Value &&value) {
|
||||
std::lock_guard<std::mutex> lock(cache_mutex_);
|
||||
|
||||
#if __cplusplus >= 201402L
|
||||
// emplace() into a map
|
||||
auto r = cache_.emplace(std::move(key), std::move(value));
|
||||
if (!r.second) {
|
||||
throw LogicError("Cache::Store: object already in cache");
|
||||
}
|
||||
#else
|
||||
// emplace_back() into a vector
|
||||
cache_.emplace_back(std::move(key), std::move(value));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Queries the cache and retrieves a matching binary. Assumes that the match is available, throws
|
||||
// otherwise.
|
||||
const std::string& GetBinaryFromCache(const std::string &device_name, const Precision &precision,
|
||||
const std::string &routine_name) {
|
||||
#ifdef VERBOSE
|
||||
printf("[DEBUG] Retrieving binary from cache\n");
|
||||
#endif
|
||||
binary_cache_mutex_.lock();
|
||||
for (auto &cached_binary: binary_cache_) {
|
||||
if (cached_binary.MatchInCache(device_name, precision, routine_name)) {
|
||||
binary_cache_mutex_.unlock();
|
||||
return cached_binary.binary;
|
||||
}
|
||||
}
|
||||
binary_cache_mutex_.unlock();
|
||||
throw LogicError("GetBinaryFromCache: Expected binary in cache, but found none");
|
||||
template <typename Key, typename Value>
|
||||
void Cache<Key, Value>::Invalidate() {
|
||||
std::lock_guard<std::mutex> lock(cache_mutex_);
|
||||
|
||||
cache_.clear();
|
||||
}
|
||||
|
||||
// Queries the cache and retrieves a matching program. Assumes that the match is available, throws
|
||||
// otherwise.
|
||||
const Program& GetProgramFromCache(const Context &context, const Precision &precision,
|
||||
const std::string &routine_name) {
|
||||
#ifdef VERBOSE
|
||||
printf("[DEBUG] Retrieving program from cache\n");
|
||||
#endif
|
||||
program_cache_mutex_.lock();
|
||||
for (auto &cached_program: program_cache_) {
|
||||
if (cached_program.MatchInCache(context(), precision, routine_name)) {
|
||||
program_cache_mutex_.unlock();
|
||||
return cached_program.program;
|
||||
}
|
||||
}
|
||||
program_cache_mutex_.unlock();
|
||||
throw LogicError("GetProgramFromCache: Expected program in cache, but found none");
|
||||
template <typename Key, typename Value>
|
||||
Cache<Key, Value> &Cache<Key, Value>::Instance() {
|
||||
return instance_;
|
||||
}
|
||||
|
||||
// Queries the cache to see whether or not the compiled kernel is already there
|
||||
bool BinaryIsInCache(const std::string &device_name, const Precision &precision,
|
||||
const std::string &routine_name) {
|
||||
binary_cache_mutex_.lock();
|
||||
for (auto &cached_binary: binary_cache_) {
|
||||
if (cached_binary.MatchInCache(device_name, precision, routine_name)) {
|
||||
binary_cache_mutex_.unlock();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
binary_cache_mutex_.unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Queries the cache to see whether or not the compiled kernel is already there
|
||||
bool ProgramIsInCache(const Context &context, const Precision &precision,
|
||||
const std::string &routine_name) {
|
||||
program_cache_mutex_.lock();
|
||||
for (auto &cached_program: program_cache_) {
|
||||
if (cached_program.MatchInCache(context(), precision, routine_name)) {
|
||||
program_cache_mutex_.unlock();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
program_cache_mutex_.unlock();
|
||||
return false;
|
||||
}
|
||||
template <typename Key, typename Value>
|
||||
Cache<Key, Value> Cache<Key, Value>::instance_;
|
||||
|
||||
// =================================================================================================
|
||||
|
||||
// Clears the cache of stored binaries and programs
|
||||
void CacheClearAll() {
|
||||
binary_cache_mutex_.lock();
|
||||
binary_cache_.clear();
|
||||
binary_cache_mutex_.unlock();
|
||||
program_cache_mutex_.lock();
|
||||
program_cache_.clear();
|
||||
program_cache_mutex_.unlock();
|
||||
}
|
||||
template class Cache<BinaryKey, std::string>;
|
||||
template std::string BinaryCache::Get(const BinaryKeyRef &, bool *) const;
|
||||
|
||||
// =================================================================================================
|
||||
|
||||
template class Cache<ProgramKey, Program>;
|
||||
template Program ProgramCache::Get(const ProgramKeyRef &, bool *) const;
|
||||
|
||||
// =================================================================================================
|
||||
|
||||
template class Cache<DatabaseKey, Database>;
|
||||
template Database DatabaseCache::Get(const DatabaseKeyRef &, bool *) const;
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
|
|
114
src/cache.hpp
114
src/cache.hpp
|
@ -15,81 +15,89 @@
|
|||
#define CLBLAST_CACHE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
|
||||
#include "utilities/utilities.hpp"
|
||||
|
||||
namespace clblast {
|
||||
// =================================================================================================
|
||||
|
||||
// The cache of compiled OpenCL binaries, along with some meta-data
|
||||
struct BinaryCache {
|
||||
std::string binary;
|
||||
std::string device_name;
|
||||
Precision precision;
|
||||
std::string routine_name_;
|
||||
// The generic thread-safe cache. We assume that the Key may be a heavyweight struct that is not
|
||||
// normally used by the caller, while the Value is either lightweight or ref-counted.
|
||||
// Hence, searching by non-Key is supported (if there is a corresponding operator<()), and
|
||||
// on Store() the Key instance is moved from the caller (because it will likely be constructed
|
||||
// as temporary at the time of Store()).
|
||||
template <typename Key, typename Value>
|
||||
class Cache {
|
||||
public:
|
||||
// Cached object is returned by-value to avoid racing with Invalidate().
|
||||
// Due to lack of std::optional<>, in case of a cache miss we return a default-constructed
|
||||
// Value and set the flag to false.
|
||||
template <typename U>
|
||||
Value Get(const U &key, bool *in_cache) const;
|
||||
|
||||
// Finds out whether the properties match
|
||||
bool MatchInCache(const std::string &ref_device, const Precision &ref_precision,
|
||||
const std::string &ref_routine) {
|
||||
return (device_name == ref_device &&
|
||||
precision == ref_precision &&
|
||||
routine_name_ == ref_routine);
|
||||
}
|
||||
};
|
||||
// We do not return references to just stored object to avoid racing with Invalidate().
|
||||
// Caller is expected to store a temporary.
|
||||
void Store(Key &&key, Value &&value);
|
||||
void Invalidate();
|
||||
|
||||
// The actual cache, implemented as a vector of the above data-type, and its mutex
|
||||
static std::vector<BinaryCache> binary_cache_;
|
||||
static std::mutex binary_cache_mutex_;
|
||||
static Cache<Key, Value> &Instance();
|
||||
|
||||
private:
|
||||
#if __cplusplus >= 201402L
|
||||
// The std::less<void> allows to search in cache by an object comparable with Key, without
|
||||
// constructing a temporary Key
|
||||
// (see http://en.cppreference.com/w/cpp/utility/functional/less_void,
|
||||
// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3657.htm,
|
||||
// http://stackoverflow.com/questions/10536788/avoiding-key-construction-for-stdmapfind)
|
||||
std::map<Key, Value, std::less<void>> cache_;
|
||||
#else
|
||||
std::vector<std::pair<Key, Value>> cache_;
|
||||
#endif
|
||||
mutable std::mutex cache_mutex_;
|
||||
|
||||
static Cache<Key, Value> instance_;
|
||||
}; // class Cache
|
||||
|
||||
// =================================================================================================
|
||||
|
||||
// The cache of compiled OpenCL programs, along with some meta-data
|
||||
struct ProgramCache {
|
||||
Program program;
|
||||
cl_context context;
|
||||
Precision precision;
|
||||
std::string routine_name_;
|
||||
// The key struct for the cache of compiled OpenCL binaries
|
||||
// Order of fields: precision, routine_name, device_name (smaller fields first)
|
||||
typedef std::tuple<Precision, std::string, std::string> BinaryKey;
|
||||
typedef std::tuple<const Precision &, const std::string &, const std::string &> BinaryKeyRef;
|
||||
|
||||
// Finds out whether the properties match
|
||||
bool MatchInCache(const cl_context ref_context, const Precision &ref_precision,
|
||||
const std::string &ref_routine) {
|
||||
return (context == ref_context &&
|
||||
precision == ref_precision &&
|
||||
routine_name_ == ref_routine);
|
||||
}
|
||||
};
|
||||
typedef Cache<BinaryKey, std::string> BinaryCache;
|
||||
|
||||
extern template class Cache<BinaryKey, std::string>;
|
||||
extern template std::string BinaryCache::Get(const BinaryKeyRef &, bool *) const;
|
||||
|
||||
// The actual cache, implemented as a vector of the above data-type, and its mutex
|
||||
static std::vector<ProgramCache> program_cache_;
|
||||
static std::mutex program_cache_mutex_;
|
||||
|
||||
// =================================================================================================
|
||||
|
||||
// Stores the compiled binary or program in the cache
|
||||
void StoreBinaryToCache(const std::string &binary, const std::string &device_name,
|
||||
const Precision &precision, const std::string &routine_name);
|
||||
void StoreProgramToCache(const Program &program, const Context &context,
|
||||
const Precision &precision, const std::string &routine_name);
|
||||
// The key struct for the cache of compiled OpenCL programs (context-dependent)
|
||||
// Order of fields: context, precision, routine_name (smaller fields first)
|
||||
typedef std::tuple<cl_context, Precision, std::string> ProgramKey;
|
||||
typedef std::tuple<const cl_context &, const Precision &, const std::string &> ProgramKeyRef;
|
||||
|
||||
// Queries the cache and retrieves a matching binary or program. Assumes that the match is
|
||||
// available, throws otherwise.
|
||||
const std::string& GetBinaryFromCache(const std::string &device_name, const Precision &precision,
|
||||
const std::string &routine_name);
|
||||
const Program& GetProgramFromCache(const Context &context, const Precision &precision,
|
||||
const std::string &routine_name);
|
||||
typedef Cache<ProgramKey, Program> ProgramCache;
|
||||
|
||||
// Queries the cache to see whether or not the compiled kernel is already there
|
||||
bool BinaryIsInCache(const std::string &device_name, const Precision &precision,
|
||||
const std::string &routine_name);
|
||||
bool ProgramIsInCache(const Context &context, const Precision &precision,
|
||||
const std::string &routine_name);
|
||||
extern template class Cache<ProgramKey, Program>;
|
||||
extern template Program ProgramCache::Get(const ProgramKeyRef &, bool *) const;
|
||||
|
||||
// =================================================================================================
|
||||
|
||||
// Clears the cache of stored binaries
|
||||
void CacheClearAll();
|
||||
class Database;
|
||||
|
||||
// The key struct for the cache of database maps.
|
||||
// Order of fields: precision, device_name, routines (smaller fields first)
|
||||
typedef std::tuple<Precision, std::string, std::vector<std::string>> DatabaseKey;
|
||||
typedef std::tuple<const Precision &, const std::string &, const std::vector<std::string> &> DatabaseKeyRef;
|
||||
|
||||
typedef Cache<DatabaseKey, Database> DatabaseCache;
|
||||
|
||||
extern template class Cache<DatabaseKey, Database>;
|
||||
extern template Database DatabaseCache::Get(const DatabaseKeyRef &, bool *) const;
|
||||
|
||||
// =================================================================================================
|
||||
} // namespace clblast
|
||||
|
|
|
@ -2165,7 +2165,8 @@ template StatusCode PUBLIC_API Omatcopy<half>(const Layout, const Transpose,
|
|||
// Clears the cache of stored binaries
|
||||
StatusCode ClearCache() {
|
||||
try {
|
||||
CacheClearAll();
|
||||
ProgramCache::Instance().Invalidate();
|
||||
BinaryCache::Instance().Invalidate();
|
||||
} catch (...) { return DispatchException(); }
|
||||
return StatusCode::kSuccess;
|
||||
}
|
||||
|
|
|
@ -361,7 +361,7 @@ enum class BuildStatus { kSuccess, kError, kInvalid };
|
|||
// C++11 version of 'cl_program'.
|
||||
class Program {
|
||||
public:
|
||||
// Note that there is no constructor based on the regular OpenCL data-type because of extra state
|
||||
Program() = default;
|
||||
|
||||
// Source-based constructor with memory management
|
||||
explicit Program(const Context &context, const std::string &source):
|
||||
|
|
|
@ -63,12 +63,11 @@ const std::unordered_map<std::string, std::string> Database::kVendorNames{
|
|||
|
||||
// Constructor, computing device properties and populating the parameter-vector from the database.
|
||||
// This takes an optional overlay database in case of custom tuning or custom kernels.
|
||||
Database::Database(const Queue &queue, const std::vector<std::string> &kernels,
|
||||
Database::Database(const Device &device, const std::vector<std::string> &kernels,
|
||||
const Precision precision, const std::vector<const DatabaseEntry*> &overlay):
|
||||
parameters_{} {
|
||||
parameters_(std::make_shared<Parameters>()) {
|
||||
|
||||
// Finds information of the current device
|
||||
auto device = queue.GetDevice();
|
||||
auto device_type = device.Type();
|
||||
auto device_vendor = device.Vendor();
|
||||
auto device_name = device.Name();
|
||||
|
@ -87,7 +86,7 @@ Database::Database(const Queue &queue, const std::vector<std::string> &kernels,
|
|||
for (auto &db: { database, overlay}) {
|
||||
search_result = Search(kernel, device_type, device_vendor, device_name, precision, db);
|
||||
if (search_result) {
|
||||
parameters_.insert(search_result->begin(), search_result->end());
|
||||
parameters_->insert(search_result->begin(), search_result->end());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +100,7 @@ Database::Database(const Queue &queue, const std::vector<std::string> &kernels,
|
|||
// Returns a list of OpenCL pre-processor defines in string form
|
||||
std::string Database::GetDefines() const {
|
||||
std::string defines{};
|
||||
for (auto ¶meter: parameters_) {
|
||||
for (auto ¶meter: *parameters_) {
|
||||
defines += "#define "+parameter.first+" "+ToString(parameter.second)+"\n";
|
||||
}
|
||||
return defines;
|
||||
|
|
|
@ -72,12 +72,14 @@ class Database {
|
|||
// The database consists of separate database entries, stored together in a vector
|
||||
static const std::vector<const DatabaseEntry*> database;
|
||||
|
||||
Database() = default;
|
||||
|
||||
// The constructor with a user-provided database overlay (potentially an empty vector)
|
||||
explicit Database(const Queue &queue, const std::vector<std::string> &routines,
|
||||
explicit Database(const Device &device, const std::vector<std::string> &routines,
|
||||
const Precision precision, const std::vector<const DatabaseEntry*> &overlay);
|
||||
|
||||
// Accessor of values by key
|
||||
size_t operator[](const std::string key) const { return parameters_.find(key)->second; }
|
||||
size_t operator[](const std::string key) const { return parameters_->find(key)->second; }
|
||||
|
||||
// Obtain a list of OpenCL pre-processor defines based on the parameters
|
||||
std::string GetDefines() const;
|
||||
|
@ -90,7 +92,7 @@ class Database {
|
|||
const std::vector<const DatabaseEntry*> &db) const;
|
||||
|
||||
// Found parameters suitable for this device/kernel
|
||||
Parameters parameters_;
|
||||
std::shared_ptr<Parameters> parameters_;
|
||||
};
|
||||
|
||||
// =================================================================================================
|
||||
|
|
|
@ -32,11 +32,34 @@ Routine::Routine(Queue &queue, EventPointer event, const std::string &name,
|
|||
event_(event),
|
||||
context_(queue_.GetContext()),
|
||||
device_(queue_.GetDevice()),
|
||||
device_name_(device_.Name()),
|
||||
db_(queue_, routines, precision_, userDatabase) {
|
||||
device_name_(device_.Name()) {
|
||||
|
||||
InitDatabase(routines, userDatabase);
|
||||
InitProgram(source);
|
||||
}
|
||||
|
||||
void Routine::InitDatabase(const std::vector<std::string> &routines,
|
||||
const std::vector<const Database::DatabaseEntry*> &userDatabase) {
|
||||
|
||||
// Queries the cache to see whether or not the kernel parameter database is already there
|
||||
bool has_db;
|
||||
db_ = DatabaseCache::Instance().Get(DatabaseKeyRef{ precision_, device_name_, routines },
|
||||
&has_db);
|
||||
if (has_db) { return; }
|
||||
|
||||
// Builds the parameter database for this device and routine set and stores it in the cache
|
||||
db_ = Database(device_, routines, precision_, userDatabase);
|
||||
DatabaseCache::Instance().Store(DatabaseKey{ precision_, device_name_, routines },
|
||||
Database{ db_ });
|
||||
}
|
||||
|
||||
void Routine::InitProgram(std::initializer_list<const char *> source) {
|
||||
|
||||
// Queries the cache to see whether or not the program (context-specific) is already there
|
||||
if (ProgramIsInCache(context_, precision_, routine_name_)) { return; }
|
||||
bool has_program;
|
||||
program_ = ProgramCache::Instance().Get(ProgramKeyRef{ context_(), precision_, routine_name_ },
|
||||
&has_program);
|
||||
if (has_program) { return; }
|
||||
|
||||
// Sets the build options from an environmental variable (if set)
|
||||
auto options = std::vector<std::string>();
|
||||
|
@ -47,11 +70,14 @@ Routine::Routine(Queue &queue, EventPointer event, const std::string &name,
|
|||
|
||||
// Queries the cache to see whether or not the binary (device-specific) is already there. If it
|
||||
// is, a program is created and stored in the cache
|
||||
if (BinaryIsInCache(device_name_, precision_, routine_name_)) {
|
||||
auto& binary = GetBinaryFromCache(device_name_, precision_, routine_name_);
|
||||
auto program = Program(device_, context_, binary);
|
||||
program.Build(device_, options);
|
||||
StoreProgramToCache(program, context_, precision_, routine_name_);
|
||||
bool has_binary;
|
||||
auto binary = BinaryCache::Instance().Get(BinaryKeyRef{ precision_, routine_name_, device_name_ },
|
||||
&has_binary);
|
||||
if (has_binary) {
|
||||
program_ = Program(device_, context_, binary);
|
||||
program_.Build(device_, options);
|
||||
ProgramCache::Instance().Store(ProgramKey{ context_(), precision_, routine_name_ },
|
||||
Program{ program_ });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -111,21 +137,23 @@ Routine::Routine(Queue &queue, EventPointer event, const std::string &name,
|
|||
#endif
|
||||
|
||||
// Compiles the kernel
|
||||
auto program = Program(context_, source_string);
|
||||
program_ = Program(context_, source_string);
|
||||
try {
|
||||
program.Build(device_, options);
|
||||
program_.Build(device_, options);
|
||||
} catch (const CLError &e) {
|
||||
if (e.status() == CL_BUILD_PROGRAM_FAILURE) {
|
||||
fprintf(stdout, "OpenCL compiler error/warning: %s\n",
|
||||
program.GetBuildInfo(device_).c_str());
|
||||
program_.GetBuildInfo(device_).c_str());
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
// Store the compiled binary and program in the cache
|
||||
const auto binary = program.GetIR();
|
||||
StoreBinaryToCache(binary, device_name_, precision_, routine_name_);
|
||||
StoreProgramToCache(program, context_, precision_, routine_name_);
|
||||
BinaryCache::Instance().Store(BinaryKey{ precision_, routine_name_, device_name_ },
|
||||
program_.GetIR());
|
||||
|
||||
ProgramCache::Instance().Store(ProgramKey{ context_(), precision_, routine_name_ },
|
||||
Program{ program_ });
|
||||
|
||||
// Prints the elapsed compilation time in case of debugging in verbose mode
|
||||
#ifdef VERBOSE
|
||||
|
|
|
@ -35,11 +35,22 @@ class Routine {
|
|||
// Base class constructor. The user database is an optional extra database to override the
|
||||
// built-in database.
|
||||
// All heavy preparation work is done inside this constructor.
|
||||
// NOTE: the caller must provide the same userDatabase for each combination of device, precision
|
||||
// and routine list, otherwise the caching logic will break.
|
||||
explicit Routine(Queue &queue, EventPointer event, const std::string &name,
|
||||
const std::vector<std::string> &routines, const Precision precision,
|
||||
const std::vector<const Database::DatabaseEntry*> &userDatabase,
|
||||
std::initializer_list<const char *> source);
|
||||
|
||||
private:
|
||||
|
||||
// Initializes program_, fetching cached program or building one
|
||||
void InitProgram(std::initializer_list<const char *> source);
|
||||
|
||||
// Initializes db_, fetching cached database or building one
|
||||
void InitDatabase(const std::vector<std::string> &routines,
|
||||
const std::vector<const Database::DatabaseEntry*> &userDatabase);
|
||||
|
||||
protected:
|
||||
|
||||
// Non-static variable for the precision
|
||||
|
@ -57,8 +68,11 @@ class Routine {
|
|||
// OpenCL device properties
|
||||
const std::string device_name_;
|
||||
|
||||
// Compiled program (either retrieved from cache or compiled in slow path)
|
||||
Program program_;
|
||||
|
||||
// Connection to the database for all the device-specific parameters
|
||||
const Database db_;
|
||||
Database db_;
|
||||
};
|
||||
|
||||
// =================================================================================================
|
||||
|
|
|
@ -43,9 +43,8 @@ void Xamax<T>::DoAmax(const size_t n,
|
|||
TestVectorIndex(1, imax_buffer, imax_offset);
|
||||
|
||||
// Retrieves the Xamax kernels from the compiled binary
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel1 = Kernel(program, "Xamax");
|
||||
auto kernel2 = Kernel(program, "XamaxEpilogue");
|
||||
auto kernel1 = Kernel(program_, "Xamax");
|
||||
auto kernel2 = Kernel(program_, "XamaxEpilogue");
|
||||
|
||||
// Creates the buffer for intermediate values
|
||||
auto temp_size = 2*db_["WGS2"];
|
||||
|
|
|
@ -43,9 +43,8 @@ void Xasum<T>::DoAsum(const size_t n,
|
|||
TestVectorScalar(1, asum_buffer, asum_offset);
|
||||
|
||||
// Retrieves the Xasum kernels from the compiled binary
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel1 = Kernel(program, "Xasum");
|
||||
auto kernel2 = Kernel(program, "XasumEpilogue");
|
||||
auto kernel1 = Kernel(program_, "Xasum");
|
||||
auto kernel2 = Kernel(program_, "XasumEpilogue");
|
||||
|
||||
// Creates the buffer for intermediate values
|
||||
auto temp_size = 2*db_["WGS2"];
|
||||
|
|
|
@ -52,8 +52,7 @@ void Xaxpy<T>::DoAxpy(const size_t n, const T alpha,
|
|||
auto kernel_name = (use_fast_kernel) ? "XaxpyFast" : "Xaxpy";
|
||||
|
||||
// Retrieves the Xaxpy kernel from the compiled binary
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel = Kernel(program, kernel_name);
|
||||
auto kernel = Kernel(program_, kernel_name);
|
||||
|
||||
// Sets the kernel arguments
|
||||
if (use_fast_kernel) {
|
||||
|
|
|
@ -52,8 +52,7 @@ void Xcopy<T>::DoCopy(const size_t n,
|
|||
auto kernel_name = (use_fast_kernel) ? "XcopyFast" : "Xcopy";
|
||||
|
||||
// Retrieves the Xcopy kernel from the compiled binary
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel = Kernel(program, kernel_name);
|
||||
auto kernel = Kernel(program_, kernel_name);
|
||||
|
||||
// Sets the kernel arguments
|
||||
if (use_fast_kernel) {
|
||||
|
|
|
@ -46,9 +46,8 @@ void Xdot<T>::DoDot(const size_t n,
|
|||
TestVectorScalar(1, dot_buffer, dot_offset);
|
||||
|
||||
// Retrieves the Xdot kernels from the compiled binary
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel1 = Kernel(program, "Xdot");
|
||||
auto kernel2 = Kernel(program, "XdotEpilogue");
|
||||
auto kernel1 = Kernel(program_, "Xdot");
|
||||
auto kernel2 = Kernel(program_, "XdotEpilogue");
|
||||
|
||||
// Creates the buffer for intermediate values
|
||||
auto temp_size = 2*db_["WGS2"];
|
||||
|
|
|
@ -43,9 +43,8 @@ void Xnrm2<T>::DoNrm2(const size_t n,
|
|||
TestVectorScalar(1, nrm2_buffer, nrm2_offset);
|
||||
|
||||
// Retrieves the Xnrm2 kernels from the compiled binary
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel1 = Kernel(program, "Xnrm2");
|
||||
auto kernel2 = Kernel(program, "Xnrm2Epilogue");
|
||||
auto kernel1 = Kernel(program_, "Xnrm2");
|
||||
auto kernel2 = Kernel(program_, "Xnrm2Epilogue");
|
||||
|
||||
// Creates the buffer for intermediate values
|
||||
auto temp_size = 2*db_["WGS2"];
|
||||
|
|
|
@ -49,8 +49,7 @@ void Xscal<T>::DoScal(const size_t n, const T alpha,
|
|||
auto kernel_name = (use_fast_kernel) ? "XscalFast" : "Xscal";
|
||||
|
||||
// Retrieves the Xscal kernel from the compiled binary
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel = Kernel(program, kernel_name);
|
||||
auto kernel = Kernel(program_, kernel_name);
|
||||
|
||||
// Sets the kernel arguments
|
||||
if (use_fast_kernel) {
|
||||
|
|
|
@ -52,8 +52,7 @@ void Xswap<T>::DoSwap(const size_t n,
|
|||
auto kernel_name = (use_fast_kernel) ? "XswapFast" : "Xswap";
|
||||
|
||||
// Retrieves the Xswap kernel from the compiled binary
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel = Kernel(program, kernel_name);
|
||||
auto kernel = Kernel(program_, kernel_name);
|
||||
|
||||
// Sets the kernel arguments
|
||||
if (use_fast_kernel) {
|
||||
|
|
|
@ -122,8 +122,7 @@ void Xgemv<T>::MatVec(const Layout layout, const Transpose a_transpose,
|
|||
}
|
||||
|
||||
// Retrieves the Xgemv kernel from the compiled binary
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel = Kernel(program, kernel_name);
|
||||
auto kernel = Kernel(program_, kernel_name);
|
||||
|
||||
// Sets the kernel arguments
|
||||
kernel.SetArgument(0, static_cast<int>(m_real));
|
||||
|
|
|
@ -53,8 +53,7 @@ void Xger<T>::DoGer(const Layout layout,
|
|||
TestVectorY(n, y_buffer, y_offset, y_inc);
|
||||
|
||||
// Retrieves the kernel from the compiled binary
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel = Kernel(program, "Xger");
|
||||
auto kernel = Kernel(program_, "Xger");
|
||||
|
||||
// Sets the kernel arguments
|
||||
kernel.SetArgument(0, static_cast<int>(a_one));
|
||||
|
|
|
@ -67,8 +67,7 @@ void Xher<T,U>::DoHer(const Layout layout, const Triangle triangle,
|
|||
const auto matching_alpha = GetAlpha(alpha);
|
||||
|
||||
// Retrieves the kernel from the compiled binary
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel = Kernel(program, "Xher");
|
||||
auto kernel = Kernel(program_, "Xher");
|
||||
|
||||
// Sets the kernel arguments
|
||||
kernel.SetArgument(0, static_cast<int>(n));
|
||||
|
|
|
@ -54,8 +54,7 @@ void Xher2<T>::DoHer2(const Layout layout, const Triangle triangle,
|
|||
TestVectorY(n, y_buffer, y_offset, y_inc);
|
||||
|
||||
// Retrieves the kernel from the compiled binary
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel = Kernel(program, "Xher2");
|
||||
auto kernel = Kernel(program_, "Xher2");
|
||||
|
||||
// Sets the kernel arguments
|
||||
kernel.SetArgument(0, static_cast<int>(n));
|
||||
|
|
|
@ -150,9 +150,6 @@ void Xgemm<T>::GemmIndirect(const size_t m, const size_t n, const size_t k,
|
|||
const auto c_one_i = (c_want_rotated) ? n_ceiled : m_ceiled;
|
||||
const auto c_two_i = (c_want_rotated) ? m_ceiled : n_ceiled;
|
||||
|
||||
// Loads the program from the database
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
|
||||
// Determines whether or not temporary matrices are needed
|
||||
auto a_no_temp = a_one == a_one_i && a_two == a_two_i && a_ld == a_one && a_offset == 0 &&
|
||||
a_do_transpose == false && a_conjugate == false;
|
||||
|
@ -178,7 +175,7 @@ void Xgemm<T>::GemmIndirect(const size_t m, const size_t n, const size_t k,
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessA.pointer(), emptyEventList,
|
||||
a_one, a_two, a_ld, a_offset, a_buffer,
|
||||
a_one_i, a_two_i, a_one_i, 0, a_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, a_do_transpose, a_conjugate);
|
||||
eventWaitList.push_back(eventProcessA);
|
||||
}
|
||||
|
@ -189,7 +186,7 @@ void Xgemm<T>::GemmIndirect(const size_t m, const size_t n, const size_t k,
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessB.pointer(), emptyEventList,
|
||||
b_one, b_two, b_ld, b_offset, b_buffer,
|
||||
b_one_i, b_two_i, b_one_i, 0, b_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, b_do_transpose, b_conjugate);
|
||||
eventWaitList.push_back(eventProcessB);
|
||||
}
|
||||
|
@ -200,13 +197,13 @@ void Xgemm<T>::GemmIndirect(const size_t m, const size_t n, const size_t k,
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessC.pointer(), emptyEventList,
|
||||
c_one, c_two, c_ld, c_offset, c_buffer,
|
||||
c_one_i, c_two_i, c_one_i, 0, c_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, c_do_transpose, false);
|
||||
eventWaitList.push_back(eventProcessC);
|
||||
}
|
||||
|
||||
// Retrieves the Xgemm kernel from the compiled binary
|
||||
auto kernel = Kernel(program, "Xgemm");
|
||||
auto kernel = Kernel(program_, "Xgemm");
|
||||
|
||||
// Sets the kernel arguments
|
||||
kernel.SetArgument(0, static_cast<int>(m_ceiled));
|
||||
|
@ -236,7 +233,7 @@ void Xgemm<T>::GemmIndirect(const size_t m, const size_t n, const size_t k,
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, event_, eventWaitList,
|
||||
c_one_i, c_two_i, c_one_i, 0, c_temp,
|
||||
c_one, c_two, c_ld, c_offset, c_buffer,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
false, c_do_transpose, false);
|
||||
}
|
||||
}
|
||||
|
@ -255,13 +252,10 @@ void Xgemm<T>::GemmDirect(const size_t m, const size_t n, const size_t k,
|
|||
const bool a_do_transpose, const bool b_do_transpose, const bool c_do_transpose,
|
||||
const bool a_conjugate, const bool b_conjugate) {
|
||||
|
||||
// Loads the program from the database
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
|
||||
// Retrieves the proper XgemmDirect kernel from the compiled binary
|
||||
const auto name = (a_do_transpose) ? (b_do_transpose ? "XgemmDirectTT" : "XgemmDirectTN") :
|
||||
(b_do_transpose ? "XgemmDirectNT" : "XgemmDirectNN");
|
||||
auto kernel = Kernel(program, name);
|
||||
auto kernel = Kernel(program_, name);
|
||||
|
||||
// Sets the kernel arguments
|
||||
kernel.SetArgument(0, static_cast<int>(m));
|
||||
|
|
|
@ -58,8 +58,7 @@ void Xhemm<T>::DoHemm(const Layout layout, const Side side, const Triangle trian
|
|||
|
||||
// Creates a general matrix from the hermitian matrix to be able to run the regular Xgemm
|
||||
// routine afterwards
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel = Kernel(program, kernel_name);
|
||||
auto kernel = Kernel(program_, kernel_name);
|
||||
|
||||
// Sets the arguments for the hermitian-to-squared kernel
|
||||
kernel.SetArgument(0, static_cast<int>(k));
|
||||
|
|
|
@ -30,6 +30,7 @@ class Xhemm: public Xgemm<T> {
|
|||
using Xgemm<T>::queue_;
|
||||
using Xgemm<T>::context_;
|
||||
using Xgemm<T>::device_;
|
||||
using Xgemm<T>::program_;
|
||||
using Xgemm<T>::db_;
|
||||
using Xgemm<T>::DoGemm;
|
||||
|
||||
|
|
|
@ -81,9 +81,6 @@ void Xher2k<T,U>::DoHer2k(const Layout layout, const Triangle triangle, const Tr
|
|||
// Decides which kernel to run: the upper-triangular or lower-triangular version
|
||||
auto kernel_name = (triangle == Triangle::kUpper) ? "XgemmUpper" : "XgemmLower";
|
||||
|
||||
// Loads the program from the database
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
|
||||
// Determines whether or not temporary matrices are needed
|
||||
auto a1_no_temp = ab_one == n_ceiled && ab_two == k_ceiled && a_ld == n_ceiled && a_offset == 0 &&
|
||||
ab_rotated == false && ab_conjugate == false;
|
||||
|
@ -116,7 +113,7 @@ void Xher2k<T,U>::DoHer2k(const Layout layout, const Triangle triangle, const Tr
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessA1.pointer(), emptyEventList,
|
||||
ab_one, ab_two, a_ld, a_offset, a_buffer,
|
||||
n_ceiled, k_ceiled, n_ceiled, 0, a1_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, ab_rotated, ab_conjugate);
|
||||
eventWaitList.push_back(eventProcessA1);
|
||||
}
|
||||
|
@ -125,7 +122,7 @@ void Xher2k<T,U>::DoHer2k(const Layout layout, const Triangle triangle, const Tr
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessA2.pointer(), emptyEventList,
|
||||
ab_one, ab_two, a_ld, a_offset, a_buffer,
|
||||
n_ceiled, k_ceiled, n_ceiled, 0, a2_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, ab_rotated, !ab_conjugate);
|
||||
eventWaitList.push_back(eventProcessA2);
|
||||
}
|
||||
|
@ -134,7 +131,7 @@ void Xher2k<T,U>::DoHer2k(const Layout layout, const Triangle triangle, const Tr
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessB1.pointer(), emptyEventList,
|
||||
ab_one, ab_two, b_ld, b_offset, b_buffer,
|
||||
n_ceiled, k_ceiled, n_ceiled, 0, b1_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, ab_rotated, ab_conjugate);
|
||||
eventWaitList.push_back(eventProcessB1);
|
||||
}
|
||||
|
@ -143,7 +140,7 @@ void Xher2k<T,U>::DoHer2k(const Layout layout, const Triangle triangle, const Tr
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessB2.pointer(), emptyEventList,
|
||||
ab_one, ab_two, b_ld, b_offset, b_buffer,
|
||||
n_ceiled, k_ceiled, n_ceiled, 0, b2_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, ab_rotated, !ab_conjugate);
|
||||
eventWaitList.push_back(eventProcessB2);
|
||||
}
|
||||
|
@ -154,12 +151,12 @@ void Xher2k<T,U>::DoHer2k(const Layout layout, const Triangle triangle, const Tr
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessC.pointer(), emptyEventList,
|
||||
n, n, c_ld, c_offset, c_buffer,
|
||||
n_ceiled, n_ceiled, n_ceiled, 0, c_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, c_rotated, false);
|
||||
eventWaitList.push_back(eventProcessC);
|
||||
|
||||
// Retrieves the XgemmUpper or XgemmLower kernel from the compiled binary
|
||||
auto kernel = Kernel(program, kernel_name);
|
||||
auto kernel = Kernel(program_, kernel_name);
|
||||
|
||||
// Sets the kernel arguments
|
||||
kernel.SetArgument(0, static_cast<int>(n_ceiled));
|
||||
|
@ -201,7 +198,7 @@ void Xher2k<T,U>::DoHer2k(const Layout layout, const Triangle triangle, const Tr
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, event_, eventWaitList,
|
||||
n_ceiled, n_ceiled, n_ceiled, 0, c_temp,
|
||||
n, n, c_ld, c_offset, c_buffer,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
false, c_rotated, false, upper, lower, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,9 +79,6 @@ void Xherk<T,U>::DoHerk(const Layout layout, const Triangle triangle, const Tran
|
|||
// Decides which kernel to run: the upper-triangular or lower-triangular version
|
||||
auto kernel_name = (triangle == Triangle::kUpper) ? "XgemmUpper" : "XgemmLower";
|
||||
|
||||
// Loads the program from the database
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
|
||||
// Determines whether or not temporary matrices are needed
|
||||
auto a_no_temp = a_one == n_ceiled && a_two == k_ceiled && a_ld == n_ceiled && a_offset == 0 &&
|
||||
a_rotated == false && a_conjugate == false;
|
||||
|
@ -109,7 +106,7 @@ void Xherk<T,U>::DoHerk(const Layout layout, const Triangle triangle, const Tran
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessA.pointer(), emptyEventList,
|
||||
a_one, a_two, a_ld, a_offset, a_buffer,
|
||||
n_ceiled, k_ceiled, n_ceiled, 0, a_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, a_rotated, a_conjugate);
|
||||
eventWaitList.push_back(eventProcessA);
|
||||
}
|
||||
|
@ -118,7 +115,7 @@ void Xherk<T,U>::DoHerk(const Layout layout, const Triangle triangle, const Tran
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessB.pointer(), emptyEventList,
|
||||
a_one, a_two, a_ld, a_offset, a_buffer,
|
||||
n_ceiled, k_ceiled, n_ceiled, 0, b_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, a_rotated, b_conjugate);
|
||||
eventWaitList.push_back(eventProcessB);
|
||||
}
|
||||
|
@ -129,12 +126,12 @@ void Xherk<T,U>::DoHerk(const Layout layout, const Triangle triangle, const Tran
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessC.pointer(), emptyEventList,
|
||||
n, n, c_ld, c_offset, c_buffer,
|
||||
n_ceiled, n_ceiled, n_ceiled, 0, c_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, c_rotated, false);
|
||||
eventWaitList.push_back(eventProcessC);
|
||||
|
||||
// Retrieves the XgemmUpper or XgemmLower kernel from the compiled binary
|
||||
auto kernel = Kernel(program, kernel_name);
|
||||
auto kernel = Kernel(program_, kernel_name);
|
||||
|
||||
// Sets the kernel arguments
|
||||
kernel.SetArgument(0, static_cast<int>(n_ceiled));
|
||||
|
@ -163,7 +160,7 @@ void Xherk<T,U>::DoHerk(const Layout layout, const Triangle triangle, const Tran
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, event_, eventWaitList,
|
||||
n_ceiled, n_ceiled, n_ceiled, 0, c_temp,
|
||||
n, n, c_ld, c_offset, c_buffer,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
false, c_rotated, false, upper, lower, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,8 +58,7 @@ void Xsymm<T>::DoSymm(const Layout layout, const Side side, const Triangle trian
|
|||
|
||||
// Creates a general matrix from the symmetric matrix to be able to run the regular Xgemm
|
||||
// routine afterwards
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel = Kernel(program, kernel_name);
|
||||
auto kernel = Kernel(program_, kernel_name);
|
||||
|
||||
// Sets the arguments for the symmetric-to-squared kernel
|
||||
kernel.SetArgument(0, static_cast<int>(k));
|
||||
|
|
|
@ -32,6 +32,7 @@ class Xsymm: public Xgemm<T> {
|
|||
using Xgemm<T>::queue_;
|
||||
using Xgemm<T>::context_;
|
||||
using Xgemm<T>::device_;
|
||||
using Xgemm<T>::program_;
|
||||
using Xgemm<T>::db_;
|
||||
using Xgemm<T>::DoGemm;
|
||||
|
||||
|
|
|
@ -77,9 +77,6 @@ void Xsyr2k<T>::DoSyr2k(const Layout layout, const Triangle triangle, const Tran
|
|||
// Decides which kernel to run: the upper-triangular or lower-triangular version
|
||||
auto kernel_name = (triangle == Triangle::kUpper) ? "XgemmUpper" : "XgemmLower";
|
||||
|
||||
// Loads the program from the database
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
|
||||
// Determines whether or not temporary matrices are needed
|
||||
auto a_no_temp = ab_one == n_ceiled && ab_two == k_ceiled && a_ld == n_ceiled && a_offset == 0 &&
|
||||
ab_rotated == false;
|
||||
|
@ -103,7 +100,7 @@ void Xsyr2k<T>::DoSyr2k(const Layout layout, const Triangle triangle, const Tran
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessA.pointer(), emptyEventList,
|
||||
ab_one, ab_two, a_ld, a_offset, a_buffer,
|
||||
n_ceiled, k_ceiled, n_ceiled, 0, a_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, ab_rotated, false);
|
||||
eventWaitList.push_back(eventProcessA);
|
||||
}
|
||||
|
@ -112,7 +109,7 @@ void Xsyr2k<T>::DoSyr2k(const Layout layout, const Triangle triangle, const Tran
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessB.pointer(), emptyEventList,
|
||||
ab_one, ab_two, b_ld, b_offset, b_buffer,
|
||||
n_ceiled, k_ceiled, n_ceiled, 0, b_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, ab_rotated, false);
|
||||
eventWaitList.push_back(eventProcessB);
|
||||
}
|
||||
|
@ -123,12 +120,12 @@ void Xsyr2k<T>::DoSyr2k(const Layout layout, const Triangle triangle, const Tran
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessC.pointer(), emptyEventList,
|
||||
n, n, c_ld, c_offset, c_buffer,
|
||||
n_ceiled, n_ceiled, n_ceiled, 0, c_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, c_rotated, false);
|
||||
eventWaitList.push_back(eventProcessC);
|
||||
|
||||
// Retrieves the XgemmUpper or XgemmLower kernel from the compiled binary
|
||||
auto kernel = Kernel(program, kernel_name);
|
||||
auto kernel = Kernel(program_, kernel_name);
|
||||
|
||||
// Sets the kernel arguments
|
||||
kernel.SetArgument(0, static_cast<int>(n_ceiled));
|
||||
|
@ -168,7 +165,7 @@ void Xsyr2k<T>::DoSyr2k(const Layout layout, const Triangle triangle, const Tran
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, event_, eventWaitList,
|
||||
n_ceiled, n_ceiled, n_ceiled, 0, c_temp,
|
||||
n, n, c_ld, c_offset, c_buffer,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
false, c_rotated, false, upper, lower, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,9 +74,6 @@ void Xsyrk<T>::DoSyrk(const Layout layout, const Triangle triangle, const Transp
|
|||
// Decides which kernel to run: the upper-triangular or lower-triangular version
|
||||
auto kernel_name = (triangle == Triangle::kUpper) ? "XgemmUpper" : "XgemmLower";
|
||||
|
||||
// Loads the program from the database
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
|
||||
// Determines whether or not temporary matrices are needed
|
||||
auto a_no_temp = a_one == n_ceiled && a_two == k_ceiled && a_ld == n_ceiled && a_offset == 0 &&
|
||||
a_rotated == false;
|
||||
|
@ -97,7 +94,7 @@ void Xsyrk<T>::DoSyrk(const Layout layout, const Triangle triangle, const Transp
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessA.pointer(), emptyEventList,
|
||||
a_one, a_two, a_ld, a_offset, a_buffer,
|
||||
n_ceiled, k_ceiled, n_ceiled, 0, a_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, a_rotated, false);
|
||||
eventWaitList.push_back(eventProcessA);
|
||||
}
|
||||
|
@ -108,12 +105,12 @@ void Xsyrk<T>::DoSyrk(const Layout layout, const Triangle triangle, const Transp
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, eventProcessC.pointer(), emptyEventList,
|
||||
n, n, c_ld, c_offset, c_buffer,
|
||||
n_ceiled, n_ceiled, n_ceiled, 0, c_temp,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
true, c_rotated, false);
|
||||
eventWaitList.push_back(eventProcessC);
|
||||
|
||||
// Retrieves the XgemmUpper or XgemmLower kernel from the compiled binary
|
||||
auto kernel = Kernel(program, kernel_name);
|
||||
auto kernel = Kernel(program_, kernel_name);
|
||||
|
||||
// Sets the kernel arguments
|
||||
kernel.SetArgument(0, static_cast<int>(n_ceiled));
|
||||
|
@ -142,7 +139,7 @@ void Xsyrk<T>::DoSyrk(const Layout layout, const Triangle triangle, const Transp
|
|||
PadCopyTransposeMatrix(queue_, device_, db_, event_, eventWaitList,
|
||||
n_ceiled, n_ceiled, n_ceiled, 0, c_temp,
|
||||
n, n, c_ld, c_offset, c_buffer,
|
||||
ConstantOne<T>(), program,
|
||||
ConstantOne<T>(), program_,
|
||||
false, c_rotated, false, upper, lower, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -70,8 +70,7 @@ void Xtrmm<T>::DoTrmm(const Layout layout, const Side side, const Triangle trian
|
|||
|
||||
// Creates a general matrix from the triangular matrix to be able to run the regular Xgemm
|
||||
// routine afterwards
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
auto kernel = Kernel(program, kernel_name);
|
||||
auto kernel = Kernel(program_, kernel_name);
|
||||
|
||||
// Sets the arguments for the triangular-to-squared kernel
|
||||
kernel.SetArgument(0, static_cast<int>(k));
|
||||
|
|
|
@ -31,6 +31,7 @@ class Xtrmm: public Xgemm<T> {
|
|||
using Xgemm<T>::queue_;
|
||||
using Xgemm<T>::context_;
|
||||
using Xgemm<T>::device_;
|
||||
using Xgemm<T>::program_;
|
||||
using Xgemm<T>::db_;
|
||||
using Xgemm<T>::DoGemm;
|
||||
|
||||
|
|
|
@ -65,14 +65,11 @@ void Xomatcopy<T>::DoOmatcopy(const Layout layout, const Transpose a_transpose,
|
|||
TestMatrixA(a_one, a_two, a_buffer, a_offset, a_ld);
|
||||
TestMatrixB(b_one, b_two, b_buffer, b_offset, b_ld);
|
||||
|
||||
// Loads the program from the database
|
||||
const auto program = GetProgramFromCache(context_, PrecisionValue<T>(), routine_name_);
|
||||
|
||||
auto emptyEventList = std::vector<Event>();
|
||||
PadCopyTransposeMatrix(queue_, device_, db_, event_, emptyEventList,
|
||||
a_one, a_two, a_ld, a_offset, a_buffer,
|
||||
b_one, b_two, b_ld, b_offset, b_buffer,
|
||||
alpha, program, false, transpose, conjugate);
|
||||
alpha, program_, false, transpose, conjugate);
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
|
|
Loading…
Reference in a new issue