summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2016-02-16 17:53:24 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2016-02-16 17:53:24 +0100
commit3743fdc534b39958c105f4124ad1130d3e8b042a (patch)
tree1385761a94fe1abb34291bf5052a3abfe45b5a6a
parentc041ce4fabcafe263bb93ca481040ed32ed5c5f2 (diff)
downloadastra-3743fdc534b39958c105f4124ad1130d3e8b042a.tar.gz
astra-3743fdc534b39958c105f4124ad1130d3e8b042a.tar.bz2
astra-3743fdc534b39958c105f4124ad1130d3e8b042a.tar.xz
astra-3743fdc534b39958c105f4124ad1130d3e8b042a.zip
Query max texture size instead of hardcoding it
-rw-r--r--cuda/3d/mem3d.cu19
-rw-r--r--cuda/3d/mem3d.h1
-rw-r--r--src/CompositeGeometryManager.cpp12
3 files changed, 26 insertions, 6 deletions
diff --git a/cuda/3d/mem3d.cu b/cuda/3d/mem3d.cu
index 6d81dc0..0320117 100644
--- a/cuda/3d/mem3d.cu
+++ b/cuda/3d/mem3d.cu
@@ -62,6 +62,25 @@ size_t availableGPUMemory()
return free;
}
+int maxBlockDimension()
+{
+ int dev;
+ cudaError_t err = cudaGetDevice(&dev);
+ if (err != cudaSuccess) {
+ ASTRA_WARN("Error querying device");
+ return 0;
+ }
+
+ cudaDeviceProp props;
+ err = cudaGetDeviceProperties(&props, dev);
+ if (err != cudaSuccess) {
+ ASTRA_WARN("Error querying device %d properties", dev);
+ return 0;
+ }
+
+ return std::min(props.maxTexture3D[0], std::min(props.maxTexture3D[1], props.maxTexture3D[2]));
+}
+
MemHandle3D allocateGPUMemory(unsigned int x, unsigned int y, unsigned int z, Mem3DZeroMode zero)
{
SMemHandle3D_internal hnd;
diff --git a/cuda/3d/mem3d.h b/cuda/3d/mem3d.h
index acb72cb..6fff80b 100644
--- a/cuda/3d/mem3d.h
+++ b/cuda/3d/mem3d.h
@@ -78,6 +78,7 @@ enum Mem3DZeroMode {
};
size_t availableGPUMemory();
+int maxBlockDimension();
MemHandle3D allocateGPUMemory(unsigned int x, unsigned int y, unsigned int z, Mem3DZeroMode zero);
diff --git a/src/CompositeGeometryManager.cpp b/src/CompositeGeometryManager.cpp
index cafc452..c9cbaaa 100644
--- a/src/CompositeGeometryManager.cpp
+++ b/src/CompositeGeometryManager.cpp
@@ -55,9 +55,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
namespace astra {
-static const size_t MAX_BLOCK_DIM = 4096;
-
-
SGPUParams* CCompositeGeometryManager::s_params = 0;
CCompositeGeometryManager::CCompositeGeometryManager()
@@ -102,6 +99,9 @@ CCompositeGeometryManager::CCompositeGeometryManager()
bool CCompositeGeometryManager::splitJobs(TJobSet &jobs, size_t maxSize, int div, TJobSet &split)
{
+ int maxBlockDim = astraCUDA3d::maxBlockDimension();
+ ASTRA_DEBUG("Found max block dim %d", maxBlockDim);
+
split.clear();
for (TJobSet::const_iterator i = jobs.begin(); i != jobs.end(); ++i)
@@ -159,17 +159,17 @@ bool CCompositeGeometryManager::splitJobs(TJobSet &jobs, size_t maxSize, int div
size_t remainingSize = ( maxSize - outputPart->getSize() ) / 2;
TPartList splitInput;
- input->splitZ(splitInput, remainingSize, MAX_BLOCK_DIM, 1);
+ input->splitZ(splitInput, remainingSize, maxBlockDim, 1);
delete input;
TPartList splitInput2;
for (TPartList::iterator i_in = splitInput.begin(); i_in != splitInput.end(); ++i_in) {
boost::shared_ptr<CPart> inputPart = *i_in;
- inputPart.get()->splitX(splitInput2, SIZE_MAX, MAX_BLOCK_DIM, 1);
+ inputPart.get()->splitX(splitInput2, SIZE_MAX, maxBlockDim, 1);
}
splitInput.clear();
for (TPartList::iterator i_in = splitInput2.begin(); i_in != splitInput2.end(); ++i_in) {
boost::shared_ptr<CPart> inputPart = *i_in;
- inputPart.get()->splitY(splitInput, SIZE_MAX, MAX_BLOCK_DIM, 1);
+ inputPart.get()->splitY(splitInput, SIZE_MAX, maxBlockDim, 1);
}
splitInput2.clear();