BMEVIIIMB01
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

81 lines
2.1 KiB

#pragma once
#include "Tests.h"
enum class MVType {
SimpleMV, ReduceMV, LargeMV
};
class MatrixVectorMultiplier {
protected:
cl::Context* context;
cl::CommandQueue* queue;
cl::Program* program;
std::string name;
public:
virtual cl_ulong dewIt(int n, int m, float* y, const float* A, const float* x, const float* b) = 0;
std::string getName() {
return name;
}
};
class Jacobi : public TestCase {
private:
int Jn;
// CPU
float* Jx_c[2] = { NULL, NULL };
float* JA_c = NULL;
float* Jb_c = NULL;
// GPU
float* Jx_g[2] = { NULL, NULL };
float* JA_g = NULL;
float* Jb_g = NULL;
MVType type;
void generateLinEq();
void cpuScalarMV(int n, int m, float* y, const float* A, const float* x, const float* b);
void printMatrix(int n, int m, float* A);
MatrixVectorMultiplier* MethodFactory(MVType type, cl::Context* context, cl::CommandQueue* queue, cl::Program* program);
public:
Jacobi(int n, MVType type);
void collect_results(cl::CommandQueue* queue);
void gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event);
void cpu_compute();
bool validate_results();
std::string description();
};
class Gauss : public TestCase {
private:
int n;
int m;
float* G;
public:
Gauss(int _n, int _m, float* _G);
void collect_results(cl::CommandQueue* queue);
void gpu_compute(cl::Context* context, cl::CommandQueue* queue, cl::Program* program, cl::Event* Event);
void cpu_compute();
bool validate_results();
std::string description();
};
class Simple : public MatrixVectorMultiplier {
public:
Simple(cl::Context* context, cl::CommandQueue* queue, cl::Program* program);
cl_ulong dewIt(int n, int m, float* y, const float* A, const float* x, const float* b);
};
class Reduce : public MatrixVectorMultiplier {
public:
Reduce(cl::Context* context, cl::CommandQueue* queue, cl::Program* program);
cl_ulong dewIt(int n, int m, float* y, const float* A, const float* x, const float* b);
};
class Large : public MatrixVectorMultiplier {
public:
Large(cl::Context* context, cl::CommandQueue* queue, cl::Program* program);
cl_ulong dewIt(int n, int m, float* y, const float* A, const float* x, const float* b);
};