Commit f52a8b1d authored by karius's avatar karius

new class structure

parent 523a545d
......@@ -942,7 +942,7 @@ __global__ void transformKernel(float* output,float4 * d_rotations, uint rot_num
//}
Density Density::from_mrc(GPUManager * manager,const char * mrc_path,int gpu_index){
Density density(manager);
Density density;
density.mrc_source.setFileName(mrc_path);
density.mrc_source.readHeader();
......
......@@ -45,7 +45,7 @@ inline size_t vol(uint4 vec){
class Density: public GPUObject {
public:
Density(GPUManager * manager) : GPUObject(manager){};
Density(){};
Density(float * const & h_coord_dim, const float & h_pixel_size);
Density(float * const & coord_dim, uint * const & padding_dim, const float & h_pixel_size);
virtual ~Density();
......
......@@ -8,6 +8,7 @@
#include <Engine.h>
#include <string>
#include <iostream>
#include <Node.h>
Engine::Engine() {
_workerthreads.resize(_gpumanager.numGPUS());
......
......@@ -22,8 +22,6 @@ public:
void killWorkers();
void startWorkers();
virtual ~Engine();
private:
GPUManager _gpumanager;
std::vector<WorkerThread *> _workerthreads;
};
......
No preview for this file type
......@@ -15,16 +15,16 @@ class GPUManager;
class GPUObject {
public:
GPUObject(GPUManager * manager):_manager(manager){};
GPUObject(){};
bool blockMemory(GPUObject * gpu_object,int gpu_index, void * gpu_mem_ptr, size_t bytes,void * cpu_mem_ptr,bool mirrored);
bool initGPUMemory(bool all = true);
bool CPUToGPU(bool all = true);
bool GPUToCPU(bool all = true);
bool ToCPU(bool all = true);
virtual ~GPUObject();
GPUManager * _manager = nullptr;
private:
friend class GPUManager;
GPUManager * _manager = nullptr;
std::map<int,std::vector<memory_unit>> _memory_units;
int _gpu_index = -1;
};
......
No preview for this file type
......@@ -33,9 +33,9 @@ manager:
g++ GPUManager.o GPUObject.o Density.o CMrcReader.o test.o link.o -o manager -lnvidia-ml -L/usr/local/cuda-10.0/lib64/ -lcudart -lcudadevrt
engine:
nvcc --gpu-architecture=$(DEVICE_ARCH) --include-path=./ --device-c Engine.cu Task.cu WorkerThread.cu GPUManager.cu GPUObject.cu Density.cu CMrcReader.cu test.cu -g -G
nvcc --gpu-architecture=$(DEVICE_ARCH) --device-link Engine.o Task.o WorkerThread.o GPUManager.o GPUObject.o Density.o CMrcReader.o test.o --output-file link.o
g++ Engine.o Task.o WorkerThread.o GPUManager.o GPUObject.o Density.o CMrcReader.o test.o link.o -o engine -lnvidia-ml -L/usr/local/cuda-10.0/lib64/ -lcudart -lcudadevrt -pthread
nvcc --gpu-architecture=$(DEVICE_ARCH) --include-path=./ --device-c Node.cu Parameter.cu ParameterSet.cu ParameterPaths.cu NodeLoadPdb.cu Engine.cu Task.cu WorkerThread.cu GPUManager.cu GPUObject.cu Density.cu CMrcReader.cu test.cu -g -G
nvcc --gpu-architecture=$(DEVICE_ARCH) --device-link Node.o Parameter.o ParameterSet.o ParameterPaths.o NodeLoadPdb.o Engine.o Task.o WorkerThread.o GPUManager.o GPUObject.o Density.o CMrcReader.o test.o --output-file link.o
g++ Node.o Parameter.o ParameterSet.o ParameterPaths.o NodeLoadPdb.o Engine.o Task.o WorkerThread.o GPUManager.o GPUObject.o Density.o CMrcReader.o test.o link.o -o engine -lnvidia-ml -L/usr/local/cuda-10.0/lib64/ -lcudart -lcudadevrt -pthread
protocol:
# sm_72 volta support, V100s
......
/*
* Node.cu
*
* Created on: Dec 17, 2020
* Author: kkarius
*/
/*
* Node.h
*
* Created on: Dec 17, 2020
* Author: kkarius
*/
#ifndef NODE_H_
#define NODE_H_
#include <ParameterSet.h>
#include <GPUObject.h>
#include <GPUManager.h>
#include <vector>
#include <Engine.h>
#include <Slot.h>
template <class IN, class OUT>
class Node : public GPUObject{
public:
Node(){};
~Node() {};
ParameterSet * own_paras = nullptr;
ParameterSet memory;
void processRequest(const ParameterSet &para_set);
void setGPUManager(GPUManager * manager){
this->_manager = manager;
if (input != nullptr){
input->_manager = manager;
}
if (output != nullptr){
output->_manager = manager;
}
}
Slot<IN> * input = nullptr;
Slot<OUT> * output = nullptr;
};
#endif /* NODE_H_ */
/*
* NodeLoadPdb.cu
*
* Created on: Dec 18, 2020
* Author: kkarius
*/
#include <NodeLoadPdb.h>
#include <ParameterSet.h>
#include <ParameterPaths.h>
#include <MemoryResources.h>
#include <Particles.h>
#include <Node.h>
#include <Slot.h>
NodeLoadPdb::NodeLoadPdb(Engine * _engine){
ParameterSet * set_para = new ParameterSet();
ParameterPaths * para_paths = new ParameterPaths("pdb_paths");
set_para->addParameter(para_paths);
own_paras = set_para;
output = new Slot<Particles>(true);
setGPUManager(&_engine->_gpumanager);
}
NodeLoadPdb::~NodeLoadPdb() {
// TODO Auto-generated destructor stub
}
/*
* NodeLoadPdb.h
*
* Created on: Dec 18, 2020
* Author: kkarius
*/
#ifndef NODELOADPDB_H_
#define NODELOADPDB_H_
#include <GPUManager.h>
#include <Engine.h>
#include <Particles.h>
#include <Node.h>
class NodeLoadPdb: public Node<void,Particles>{
public:
NodeLoadPdb(Engine * _engine);
virtual ~NodeLoadPdb();
};
#endif /* NODELOADPDB_H_ */
......@@ -13,15 +13,15 @@
class Parameter {
public:
Parameter(const char * name):_name(name){};
Parameter(const char * name,float from, float to, float init):_name(name),_from(from),_to(to),_init(init){};
// Parameter(const char * name,float from, float to, float init):_name(name),_from(from),_to(to),_init(init){};
std::string name(void){return std::string(_name);}
float continuousValue(int i = 0){return _init;};
// float continuousValue(int i = 0){return _init;};
virtual ~Parameter();
private:
const char * _name = nullptr;
float _from = 0;
float _to = 0;
float _init = 0;
// float _from = 0;
// float _to = 0;
// float _init = 0;
};
#endif /* PARAMETER_H_ */
/*
* ParameterPaths.cu
*
* Created on: Dec 18, 2020
* Author: kkarius
*/
#include <ParameterPaths.h>
ParameterPaths::~ParameterPaths() {
// TODO Auto-generated destructor stub
}
/*
* ParameterPaths.h
*
* Created on: Dec 18, 2020
* Author: kkarius
*/
#ifndef PARAMETERPATHS_H_
#define PARAMETERPATHS_H_
#include <Parameter.h>
#include <vector>
class ParameterPaths : public Parameter {
public:
ParameterPaths(const char * _name):Parameter(_name){};
virtual ~ParameterPaths();
private:
std::vector<const char *> _paths;
};
#endif /* PARAMETERPATHS_H_ */
......@@ -15,11 +15,11 @@
class ParameterSet {
public:
ParameterSet();
void addParameter(Parameter parameter){_parameters[parameter.name()] = parameter;}
Parameter getParameter(const char * name){return _parameters[std::string(name)];}
void addParameter(Parameter * parameter){_parameters[parameter->name()] = parameter;}
Parameter * getParameter(const char * name){return _parameters[std::string(name)];}
virtual ~ParameterSet();
private:
std::map<std::string,Parameter> _parameters;
std::map<std::string,Parameter *> _parameters;
};
#endif /* PARAMETERSET_H_ */
/*
* Slot.h
*
* Created on: Dec 17, 2020
* Author: kkarius
*/
#ifndef SLOT_H_
#define SLOT_H_
#include <GPUObject.h>
#include <ParameterSet.h>
template <class T>
class Slot: public GPUObject {
public:
Slot( bool _is_output):is_output(_is_output){};
~Slot(){};
T * request(ParameterSet para_set);
bool is_output = true;
};
#endif /* SLOT_H_ */
......@@ -28,6 +28,7 @@
#include <Engine.h>
#include <thread>
#include <chrono>
#include <NodeLoadPdb.h>
using namespace std::chrono_literals;
BOOST_AUTO_TEST_CASE(general_engine_test)
......@@ -35,13 +36,14 @@ BOOST_AUTO_TEST_CASE(general_engine_test)
printf(" ======================================== Engine Test =====================================\n");
printf(" ============================= ++++++++++++++++++++++++++++++++ ===========================\n");
Engine engine;
engine.startWorkers();
engine.submitTask(std::shared_ptr<Task>(new Task("Yay0")),0);
engine.submitTask(std::shared_ptr<Task>(new Task("Yay1")),1);
engine.submitTask(std::shared_ptr<Task>(new Task("Yay2")),2);
engine.submitTask(std::shared_ptr<Task>(new Task("Yay3")),3);
std::this_thread::sleep_for(1s);
engine.killWorkers();
// engine.startWorkers();
// engine.submitTask(std::shared_ptr<Task>(new Task("Yay0")),0);
// engine.submitTask(std::shared_ptr<Task>(new Task("Yay1")),1);
// engine.submitTask(std::shared_ptr<Task>(new Task("Yay2")),2);
// engine.submitTask(std::shared_ptr<Task>(new Task("Yay3")),3);
// std::this_thread::sleep_for(1s);
// engine.killWorkers();
NodeLoadPdb loadpdb(&engine);
// std::pair<float3,float3> effective_translational_shift;
// effective_translational_shift.first = {0,0,0};
// effective_translational_shift.second = {2,2,2};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment