Skip to content
Snippets Groups Projects
Commit 834298af authored by Eric Wait's avatar Eric Wait
Browse files

Added a more verbose version of getting the stats for the devices

parent 0b97b468
No related branches found
No related tags found
No related merge requests found
Showing
with 172 additions and 5 deletions
......@@ -7,6 +7,7 @@ methods (Static)
imageOut = ApplyPolyTransformation(imageIn,a,b,c,min,max,device)
imageOut = ContrastEnhancement(imageIn,sigma,MedianNeighborhood,device)
[numCudaDevices,memoryStats] = DeviceCount()
deviceStatsArray = DeviceStats()
imageOut = GaussianFilter(imageIn,sigma,device)
histogram = Histogram(imageIn,numBins,min,max,device)
imageOut = ImagePow(imageIn,power,device)
......
% DeviceCount - This will return statistics on the Cuda devices available.
% DeviceCount - This will return the number of Cuda devices available, and their memory.
% [numCudaDevices,memoryStats] = ImProc.Cuda.DeviceCount()
% NumCudaDevices -- this is the number of Cuda devices available.
% MemoryStats -- this is an array of structures where each entery corresponds to a Cuda device.
% MemoryStats -- this is an array of structures where each entry corresponds to a Cuda device.
% The memory structure contains the total memory on the device and the memory available for a Cuda call.
function [numCudaDevices,memoryStats] = DeviceCount()
[numCudaDevices,memoryStats] = ImProc.Cuda.Mex('DeviceCount');
......
% DeviceStats - This will return the statistics of each Cuda capable device installed.
% deviceStatsArray = ImProc.Cuda.DeviceStats()
% DeviceStatsArray -- this is an array of structs, one struct per device.
% The struct has these fields: name, major, minor, constMem, sharedMem, totalMem, tccDriver, mpCount, threadsPerMP, warpSize, maxThreads.
function deviceStatsArray = DeviceStats()
[deviceStatsArray] = ImProc.Cuda.Mex('DeviceStats');
end
No preview for this file type
......@@ -3,7 +3,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
excludeList = ...
{'Cuda.m';
'DeviceCount.m'};
'DeviceCount.m';
'DeviceStats.m'};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% remember curent path
......
% DeviceStats - This will return the statistics of each Cuda capable device installed.
% deviceStatsArray = ImProc.Devic);
% DeviceStatsArray -- this is an array of structs, one struct per device.
% The struct has these fields: name, major, minor, constMem, sharedMem, totalMem, tccDriver, mpCount, threadsPerMP, warpSize, maxThreads.
function deviceStatsArray = DeviceStats()
end
......@@ -2,6 +2,7 @@
#include "CudaAdd.cuh"
#include "CudaContrastEnhancement.cuh"
#include "CudaDeviceCount.cuh"
#include "CudaDeviceStats.h"
#include "CudaHistogram.cuh"
#include "CudaImageCopy.cuh"
#include "CudaGaussianFilter.cuh"
......@@ -181,6 +182,11 @@ void clearDevice()
}
int deviceStats(DevStats** stats)
{
return cDeviceStats(stats);
}
size_t* histogram(const unsigned char* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned char minVal/*=std::numeric_limits<unsigned char>::lowest()*/, unsigned char maxVal/*=std::numeric_limits<unsigned char>::max()*/, int device/*=0*/)
{
return cCalculateHistogram(imageIn,dims,arraySize,minVal,maxVal,device);
......
#pragma once
#include "Vec.h"
#include "CudaDeviceStats.h"
#include <limits>
#ifdef IMAGE_PROCESSOR_DLL
......@@ -47,6 +48,7 @@ IMAGE_PROCESSOR_API float* contrastEnhancement(const float* imageIn, Vec<size_t>
IMAGE_PROCESSOR_API double* contrastEnhancement(const double* imageIn, Vec<size_t> dims, Vec<float> sigmas, Vec<size_t> neighborhood, double** imageOut = NULL, int device = 0);
IMAGE_PROCESSOR_API int deviceCount();
IMAGE_PROCESSOR_API int deviceStats(DevStats** stats);
IMAGE_PROCESSOR_API size_t* histogram(const unsigned char* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned char minVal = std::numeric_limits<unsigned char>::lowest(), unsigned char maxVal = std::numeric_limits<unsigned char>::max(), int device = 0);
IMAGE_PROCESSOR_API size_t* histogram(const unsigned short* imageIn, Vec<size_t> dims, unsigned int arraySize, unsigned short minVal = std::numeric_limits<unsigned short>::lowest(), unsigned short maxVal = std::numeric_limits<unsigned short>::max(), int device = 0);
......
#include "CudaDeviceStats.h"
#include <cuda_runtime.h>
int cDeviceStats(DevStats** stats)
{
int cnt = 0;
cudaGetDeviceCount(&cnt);
*stats = new DevStats[cnt];
for(int device = 0; device<cnt; ++device)
{
cudaDeviceProp props;
cudaGetDeviceProperties(&props, device);
DevStats* curStats = (*stats)+device;
curStats->name = props.name;
curStats->major = props.major;
curStats->minor = props.minor;
curStats->constMem = props.totalConstMem;
curStats->sharedMem = props.sharedMemPerBlock;
curStats->totalMem = props.totalGlobalMem;
curStats->tccDriver = props.tccDriver>0;
curStats->mpCount = props.multiProcessorCount;
curStats->threadsPerMP = props.maxThreadsPerMultiProcessor;
curStats->warpSize = props.warpSize;
curStats->maxThreads = props.maxThreadsPerBlock;
}
return cnt;
}
\ No newline at end of file
#pragma once
#include <string>
struct DevStats
{
std::string name;
int major;
int minor;
size_t constMem;
size_t sharedMem;
size_t totalMem;
bool tccDriver;
int mpCount;
int threadsPerMP;
int warpSize;
int maxThreads;
};
int cDeviceStats(DevStats** stats);
......@@ -26,6 +26,7 @@
<ClInclude Include="Cuda\CudaConvertType.cuh" />
<ClInclude Include="Cuda\CudaDeviceCount.cuh" />
<ClInclude Include="Cuda\CudaDeviceImages.cuh" />
<ClInclude Include="Cuda\CudaDeviceStats.h" />
<ClInclude Include="Cuda\CudaGaussianFilter.cuh" />
<ClInclude Include="Cuda\CudaGetMinMax.cuh" />
<ClInclude Include="Cuda\CudaGetROI.cuh" />
......@@ -67,6 +68,9 @@
<ClCompile Include="Cuda\CHelpers.cpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Cuda\CudaDeviceStats.cpp">
<FileType>Document</FileType>
</ClCompile>
<CudaCompile Include="Cuda\CudaUtilities.cu" />
<CudaCompile Include="Cuda\CWrappers.cu" />
<CudaCompile Include="Cuda\ImageChunk.cu" />
......
......@@ -140,11 +140,17 @@
<ClInclude Include="Cuda\CudaClamp.cuh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Cuda\CudaDeviceStats.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Cuda\CHelpers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Cuda\CudaDeviceStats.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CudaCompile Include="Cuda\CudaUtilities.cu">
......
......@@ -25,6 +25,7 @@
<ClInclude Include="Cuda\CudaConvertType.cuh" />
<ClInclude Include="Cuda\CudaDeviceCount.cuh" />
<ClInclude Include="Cuda\CudaDeviceImages.cuh" />
<ClInclude Include="Cuda\CudaDeviceStats.h" />
<ClInclude Include="Cuda\CudaGaussianFilter.cuh" />
<ClInclude Include="Cuda\CudaGetMinMax.cuh" />
<ClInclude Include="Cuda\CudaGetROI.cuh" />
......@@ -62,6 +63,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="Cuda\CHelpers.cpp" />
<ClCompile Include="Cuda\CudaDeviceStats.cpp" />
</ItemGroup>
<ItemGroup>
<CudaCompile Include="Cuda\CudaUtilities.cu" />
......
......@@ -131,11 +131,17 @@
<ClInclude Include="Cuda\CudaStdFilter.cuh">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Cuda\CudaDeviceStats.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Cuda\CHelpers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Cuda\CudaDeviceStats.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CudaCompile Include="Cuda\CudaUtilities.cu">
......
......@@ -104,6 +104,7 @@ copy $(OutDir)CudaMex.dll "$(ProjectDir)Mex.mexw64"</Command>
<ClCompile Include="Mex\MexCommand.cpp" />
<ClCompile Include="Mex\MexContrastEnhancement.cpp" />
<ClCompile Include="Mex\MexDeviceCount.cpp" />
<ClCompile Include="Mex\MexDeviceStats.cpp" />
<ClCompile Include="Mex\MexGaussianFilter.cpp" />
<ClCompile Include="Mex\MexHistogram.cpp" />
<ClCompile Include="Mex\MexImagePow.cpp" />
......
......@@ -140,6 +140,9 @@
<ClCompile Include="Mex\MexCommand.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Mex\MexDeviceStats.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Mex\CudaMex.def">
......
No preview for this file type
......@@ -43,6 +43,7 @@ DEF_MEX_COMMAND(AddImageWith)
DEF_MEX_COMMAND(ApplyPolyTransformation)
DEF_MEX_COMMAND(ContrastEnhancement)
DEF_MEX_COMMAND(DeviceCount)
DEF_MEX_COMMAND(DeviceStats)
DEF_MEX_COMMAND(GaussianFilter)
DEF_MEX_COMMAND(Histogram)
DEF_MEX_COMMAND(ImagePow)
......
......@@ -42,9 +42,9 @@ void MexDeviceCount::usage(std::vector<std::string>& outArgs,std::vector<std::st
void MexDeviceCount::help(std::vector<std::string>& helpLines) const
{
helpLines.push_back("This will return statistics on the Cuda devices available.");
helpLines.push_back("This will return the number of Cuda devices available, and their memory.");
helpLines.push_back("\tNumCudaDevices -- this is the number of Cuda devices available.");
helpLines.push_back("\tMemoryStats -- this is an array of structures where each entery corresponds to a Cuda device.");
helpLines.push_back("\tMemoryStats -- this is an array of structures where each entry corresponds to a Cuda device.");
helpLines.push_back("\t\tThe memory structure contains the total memory on the device and the memory available for a Cuda call.");
}
\ No newline at end of file
#include "MexCommand.h"
#include "CWrappers.h"
#include "../Cuda/CudaDeviceStats.h"
void MexDeviceStats::execute(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const
{
DevStats* devStats;
int numDevices = deviceStats(&devStats);
mwSize dims[2] = {numDevices,1};
const char* fieldNames[] = {"name", "major", "minor", "constMem", "sharedMem", "totalMem", "tccDriver", "mpCount", "threadsPerMP", "warpSize", "maxThreads"};
plhs[0] = mxCreateStructArray(2, dims, 11, fieldNames);
int name_field = mxGetFieldNumber(plhs[0], "name");
int major_field = mxGetFieldNumber(plhs[0], "major");
int minor_field = mxGetFieldNumber(plhs[0], "minor");
int constMem_field = mxGetFieldNumber(plhs[0], "constMem");
int sharedMem_field = mxGetFieldNumber(plhs[0], "sharedMem");
int totalMem_field = mxGetFieldNumber(plhs[0], "totalMem");
int tccDriver_field = mxGetFieldNumber(plhs[0], "tccDriver");
int mpCount_field = mxGetFieldNumber(plhs[0], "mpCount");
int threadsPerMP_field = mxGetFieldNumber(plhs[0], "threadsPerMP");
int warpSize_field = mxGetFieldNumber(plhs[0], "warpSize");
int maxThreads_field = mxGetFieldNumber(plhs[0], "maxThreads");
for(int device = 0; device<numDevices; ++device)
{
DevStats curDevice = devStats[device];
mxSetFieldByNumber(plhs[0], device, name_field, mxCreateString(curDevice.name.c_str()));
mxSetFieldByNumber(plhs[0], device, major_field, mxCreateDoubleScalar(curDevice.major));
mxSetFieldByNumber(plhs[0], device, minor_field, mxCreateDoubleScalar(curDevice.minor));
mxSetFieldByNumber(plhs[0], device, constMem_field, mxCreateDoubleScalar(curDevice.constMem));
mxSetFieldByNumber(plhs[0], device, sharedMem_field, mxCreateDoubleScalar(curDevice.sharedMem));
mxSetFieldByNumber(plhs[0], device, totalMem_field, mxCreateDoubleScalar(curDevice.totalMem));
mxSetFieldByNumber(plhs[0], device, tccDriver_field, mxCreateLogicalScalar(curDevice.tccDriver));
mxSetFieldByNumber(plhs[0], device, mpCount_field, mxCreateDoubleScalar(curDevice.mpCount));
mxSetFieldByNumber(plhs[0], device, threadsPerMP_field, mxCreateDoubleScalar(curDevice.threadsPerMP));
mxSetFieldByNumber(plhs[0], device, warpSize_field, mxCreateDoubleScalar(curDevice.warpSize));
mxSetFieldByNumber(plhs[0], device, maxThreads_field, mxCreateDoubleScalar(curDevice.maxThreads));
}
delete[] devStats;
}
std::string MexDeviceStats::check(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) const
{
if(nlhs<1)
return "Requires one output!";
return "";
}
void MexDeviceStats::usage(std::vector<std::string>& outArgs, std::vector<std::string>& inArgs) const
{
outArgs.push_back("deviceStatsArray");
}
void MexDeviceStats::help(std::vector<std::string>& helpLines) const
{
helpLines.push_back("This will return the statistics of each Cuda capable device installed.");
helpLines.push_back("\tDeviceStatsArray -- this is an array of structs, one struct per device.");
helpLines.push_back("\t\tThe struct has these fields: name, major, minor, constMem, sharedMem, totalMem, tccDriver, mpCount, threadsPerMP, warpSize, maxThreads.");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment