本文整理汇总了C++中OptionParser::getOptionString方法的典型用法代码示例。如果您正苦于以下问题:C++ OptionParser::getOptionString方法的具体用法?C++ OptionParser::getOptionString怎么用?C++ OptionParser::getOptionString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptionParser
的用法示例。
在下文中一共展示了OptionParser::getOptionString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunTest
void RunTest(cl_device_id dev, cl_context ctx, cl_command_queue queue,
ResultDatabase &resultDB, OptionParser &op, string compileFlags,
int nRows=0)
{
// Determine if the device is capable of using images in general
cl_device_id device_id;
cl_bool deviceSupportsImages;
int err = 0;
err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE, sizeof(device_id),
&device_id, NULL);
CL_CHECK_ERROR(err);
err = clGetDeviceInfo(device_id, CL_DEVICE_IMAGE_SUPPORT,
sizeof(deviceSupportsImages), &deviceSupportsImages, NULL);
CL_CHECK_ERROR(err);
size_t maxImgWidth = 0;
err = clGetDeviceInfo(device_id, CL_DEVICE_IMAGE2D_MAX_WIDTH,
sizeof(size_t), &maxImgWidth, NULL);
CL_CHECK_ERROR(err);
// Make sure our sampler type is supported
cl_sampler sampler;
sampler = clCreateSampler(ctx, CL_FALSE, CL_ADDRESS_NONE,
CL_FILTER_NEAREST, &err);
if (err != CL_SUCCESS)
{
cout << "Warning: Device does not support required sampler type";
cout << " falling back to global memory\n";
deviceSupportsImages = false;
} else
{
clReleaseSampler(sampler);
}
// Host data structures
// array of values in the sparse matrix
floatType *h_val, *h_valPad;
// array of column indices for each value in h_val
int *h_cols, *h_colsPad;
// array of indices to the start of each row in h_val/valPad
int *h_rowDelimiters, *h_rowDelimitersPad;
// Dense vector of values
floatType *h_vec;
// Output vector
floatType *h_out;
// Reference solution computed by cpu
floatType *refOut;
int nItems; // number of non-zero elements in the matrix
int nItemsPadded;
int numRows; // number of rows in the matrix
// This benchmark either reads in a matrix market input file or
// generates a random matrix
string inFileName = op.getOptionString("mm_filename");
if (inFileName == "random")
{
// If we're not opening a file, the dimension of the matrix
// has been passed in as an argument
numRows = nRows;
nItems = numRows * numRows / 100; // 1% of entries will be non-zero
float maxval = op.getOptionFloat("maxval");
h_val = new floatType[nItems];
h_cols = new int[nItems];
h_rowDelimiters = new int[nRows+1];
fill(h_val, nItems, maxval);
initRandomMatrix(h_cols, h_rowDelimiters, nItems, numRows);
}
else
{ char filename[FIELD_LENGTH];
strcpy(filename, inFileName.c_str());
readMatrix(filename, &h_val, &h_cols, &h_rowDelimiters,
&nItems, &numRows);
}
// Final Image Check -- Make sure the image format is supported.
int imgHeight = (numRows+maxImgWidth-1)/maxImgWidth;
cl_image_format fmt;
fmt.image_channel_data_type = CL_FLOAT;
if(sizeof(floatType)==4)
{
fmt.image_channel_order=CL_R;
}
else
{
fmt.image_channel_order=CL_RG;
}
cl_mem d_vec = clCreateImage2D(ctx, CL_MEM_READ_ONLY, &fmt, maxImgWidth,
imgHeight, 0, NULL, &err);
if (err != CL_SUCCESS)
{
deviceSupportsImages = false;
} else {
clReleaseMemObject(d_vec);
}
//.........这里部分代码省略.........
示例2: InvalidArgValue
void
DoTest( const char* timerDesc, ResultDatabase& resultDB, OptionParser& opts )
{
StencilFactory<T>* stdStencilFactory = NULL;
Stencil<T>* stdStencil = NULL;
StencilFactory<T>* testStencilFactory = NULL;
Stencil<T>* testStencil = NULL;
try
{
#if defined(PARALLEL)
stdStencilFactory = new MPIHostStencilFactory<T>;
testStencilFactory = new MPICUDAStencilFactory<T>;
#else
stdStencilFactory = new HostStencilFactory<T>;
testStencilFactory = new CUDAStencilFactory<T>;
#endif // defined(PARALLEL)
assert( (stdStencilFactory != NULL) && (testStencilFactory != NULL) );
// do a sanity check on option values
CheckOptions( opts );
stdStencilFactory->CheckOptions( opts );
testStencilFactory->CheckOptions( opts );
// extract and validate options
std::vector<long long> arrayDims = opts.getOptionVecInt( "customSize" );
if( arrayDims.size() != 2 )
{
cerr << "Dim size: " << arrayDims.size() << "\n";
throw InvalidArgValue( "all overall dimensions must be positive" );
}
if (arrayDims[0] == 0) // User has not specified a custom size
{
int sizeClass = opts.getOptionInt("size");
arrayDims = StencilFactory<T>::GetStandardProblemSize( sizeClass );
}
long int seed = (long)opts.getOptionInt( "seed" );
bool beVerbose = opts.getOptionBool( "verbose" );
unsigned int nIters = (unsigned int)opts.getOptionInt( "num-iters" );
double valErrThreshold = (double)opts.getOptionFloat( "val-threshold" );
unsigned int nValErrsToPrint = (unsigned int)opts.getOptionInt( "val-print-limit" );
#if defined(PARALLEL)
unsigned int haloWidth = (unsigned int)opts.getOptionInt( "iters-per-exchange" );
#else
unsigned int haloWidth = 1;
#endif // defined(PARALLEL)
float haloVal = (float)opts.getOptionFloat( "haloVal" );
// build a description of this experiment
std::vector<long long> lDims = opts.getOptionVecInt( "lsize" );
assert( lDims.size() == 2 );
std::ostringstream experimentDescriptionStr;
experimentDescriptionStr
<< nIters << ':'
<< arrayDims[0] << 'x' << arrayDims[1] << ':'
<< lDims[0] << 'x' << lDims[1];
unsigned int nPasses = (unsigned int)opts.getOptionInt( "passes" );
unsigned int nWarmupPasses = (unsigned int)opts.getOptionInt( "warmupPasses" );
// compute the expected result on the host
// or read it from a pre-existing file
std::string matrixFilenameBase = (std::string)opts.getOptionString( "expMatrixFile" );
#if defined(PARALLEL)
int cwrank;
MPI_Comm_rank( MPI_COMM_WORLD, &cwrank );
if( cwrank == 0 )
{
#endif // defined(PARALLEL)
if( !matrixFilenameBase.empty() )
{
std::cout << "\nReading expected stencil operation result from file for later comparison with CUDA output\n"
<< std::endl;
}
else
{
std::cout << "\nPerforming stencil operation on host for later comparison with CUDA output\n"
<< "Depending on host capabilities, this may take a while."
<< std::endl;
}
#if defined(PARALLEL)
}
#endif // defined(PARALLEL)
Matrix2D<T> expected( arrayDims[0] + 2*haloWidth,
arrayDims[1] + 2*haloWidth );
Initialize<T> init( seed, haloWidth, haloVal );
bool haveExpectedData = false;
if( ! matrixFilenameBase.empty() )
{
bool readOK = ReadMatrixFromFile( expected, GetMatrixFileName<T>( matrixFilenameBase ) );
if( readOK )
{
if( (expected.GetNumRows() != arrayDims[0] + 2*haloWidth) ||
(expected.GetNumColumns() != arrayDims[1] + 2*haloWidth) )
{
//.........这里部分代码省略.........