Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
clfAlgorithm.cpp
1 /*
2  * clfAlgorithm.cpp
3  *
4  * Created on: Nov 1, 2011
5  * Author: fkellner
6  */
7 
8 #include <OpenCLFramework/Algorithm/clfAlgorithm.hh>
9 #include <Base/Common/BIASpragma.hh>
10 
11 namespace BIAS {
12 
14  context_ = NULL;
15  programCL_ = NULL;
16  isSharedGL_ = false;
17  ownContext_ = false;
18  device_ = 0;
19  maxComputeUnits_ = 0;
20 }
21 
22 clfAlgorithm::clfAlgorithm(clfContext *ctx, bool sharedGL, unsigned int device) {
23  InitInternal_(ctx, sharedGL, device);
24 }
25 
27  delete programCL_;
28  if (ownContext_) {
29  delete context_;
30  }
31 }
32 
33 void clfAlgorithm::InitInternal_(clfContext *ctx, bool sharedGL, unsigned int device) {
34  if (ctx == NULL) {
35  ownContext_ = true;
36  context_ = new clfContext(sharedGL);
37  if (device < context_->GetNumDevices()) {
38  context_->SetActiveDevice(device);
39  } else {
40  device = 0;
41  }
42  } else {
43  context_ = ctx;
44  sharedGL = context_->IsSharedGLContext();
45  ownContext_ = false;
46  }
47  isSharedGL_ = sharedGL;
50  device_ = device;
51 }
52 
53 void clfAlgorithm::getlocsize(const unsigned int val, unsigned int &result) {
54  result=clfAlgorithm::getlocsize(val);
55 }
56 
57 unsigned int clfAlgorithm::getlocsize(const unsigned int val) {
58  //if (val%32==0) return 32;
59  if (val%16==0) return 16;
60  if (val%8==0) return 8;
61  return 0;
62 }
63 
64 
65 } /* namespace BIAS */
clfProgram * programCL_
Definition: clfAlgorithm.hh:35
void InitInternal_(clfContext *ctx, bool sharedGL, unsigned int device)
clfProgram * CreateProgram()
create program object
Definition: clfContext.hh:71
OpenCL Context wrapper.
Definition: clfContext.hh:49
static void getlocsize(const unsigned int val, unsigned int &result)
clfDeviceInfo GetDeviceInfo(unsigned int device=0)
Definition: clfContext.hh:141
bool IsSharedGLContext()
Definition: clfContext.hh:145
clfContext * context_
Definition: clfAlgorithm.hh:34
virtual ~clfAlgorithm()
void SetActiveDevice(unsigned int device)
Definition: clfContext.cpp:403