本文整理汇总了C++中prog函数的典型用法代码示例。如果您正苦于以下问题:C++ prog函数的具体用法?C++ prog怎么用?C++ prog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_with_source
/**
* In case BOOST_COMPUTE_USE_OFFLINE_CACHE macro is defined,
* the compiled binary is stored for reuse in the offline cache located in
* $HOME/.boost_compute on UNIX-like systems and in %APPDATA%/boost_compute
* on Windows.
*/
static program build_with_source(
const std::string &source,
const context &context,
const std::string &options = std::string()
)
{
#ifdef BOOST_COMPUTE_USE_OFFLINE_CACHE
// Get hash string for the kernel.
std::string hash;
{
device d(context.get_device());
platform p(d.get_info<cl_platform_id>(CL_DEVICE_PLATFORM));
std::ostringstream src;
src << "// " << p.name() << " v" << p.version() << "\n"
<< "// " << context.get_device().name() << "\n"
<< "// " << options << "\n\n"
<< source;
hash = detail::sha1(src.str());
}
// Try to get cached program binaries:
try {
boost::optional<program> prog = load_program_binary(hash, context);
if (prog) {
prog->build(options);
return *prog;
}
} catch (...) {
// Something bad happened. Fallback to normal compilation.
}
// Cache is apparently not available. Just compile the sources.
#endif
const char *source_string = source.c_str();
cl_int error = 0;
cl_program program_ = clCreateProgramWithSource(context,
uint_(1),
&source_string,
0,
&error);
if(!program_){
BOOST_THROW_EXCEPTION(runtime_exception(error));
}
program prog(program_, false);
prog.build(options);
#ifdef BOOST_COMPUTE_USE_OFFLINE_CACHE
// Save program binaries for future reuse.
save_program_binary(hash, prog);
#endif
return prog;
}
示例2: initWorkspaces
/**
* Executes the algorithm
*
*/
void ConvertToConstantL2::exec() {
initWorkspaces();
// Calculate the number of spectra in this workspace
const size_t numberOfSpectra = m_inputWS->getNumberHistograms();
API::Progress prog(this, 0.0, 1.0, numberOfSpectra);
int64_t numberOfSpectra_i =
static_cast<int64_t>(numberOfSpectra); // cast to make openmp happy
const auto &inputSpecInfo = m_inputWS->spectrumInfo();
auto &outputDetInfo = m_outputWS->mutableDetectorInfo();
// Loop over the histograms (detector spectra)
PARALLEL_FOR_IF(Kernel::threadSafe(*m_inputWS, *m_outputWS))
for (int64_t i = 0; i < numberOfSpectra_i; ++i) {
PARALLEL_START_INTERUPT_REGION
m_outputWS->setHistogram(i, m_inputWS->histogram(i));
// Should not move the monitors
if (inputSpecInfo.isMonitor(i))
continue;
// Throw if detector doesn't exist or is a group
if (!inputSpecInfo.hasUniqueDetector(i)) {
const auto errorMsg =
boost::format("The detector for spectrum number %d was either not "
"found, or is a group.") %
i;
throw std::runtime_error(errorMsg.str());
}
// subract the diference in l2
double thisDetL2 = inputSpecInfo.l2(i);
double deltaL2 = std::abs(thisDetL2 - m_l2);
double deltaTOF = calculateTOF(deltaL2);
deltaTOF *= 1e6; // micro sec
// position - set all detector distance to constant l2
double r, theta, phi;
V3D oldPos = inputSpecInfo.position(i);
oldPos.getSpherical(r, theta, phi);
V3D newPos;
newPos.spherical(m_l2, theta, phi);
const auto detIndex = inputSpecInfo.spectrumDefinition(i)[0];
outputDetInfo.setPosition(detIndex, newPos);
m_outputWS->mutableX(i) -= deltaTOF;
prog.report("Aligning elastic line...");
PARALLEL_END_INTERUPT_REGION
} // end for i
PARALLEL_CHECK_INTERUPT_REGION
this->setProperty("OutputWorkspace", this->m_outputWS);
}
示例3: devPosNCC
void TLDDetector::ocl_batchSrSc(const Mat_<uchar>& patches, double *resultSr, double *resultSc, int numOfPatches)
{
UMat devPatches = patches.getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY);
UMat devPositiveSamples = posExp->getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY);
UMat devNegativeSamples = negExp->getUMat(ACCESS_READ, USAGE_ALLOCATE_DEVICE_MEMORY);
UMat devPosNCC(MAX_EXAMPLES_IN_MODEL, numOfPatches, CV_32FC1, ACCESS_RW, USAGE_ALLOCATE_DEVICE_MEMORY);
UMat devNegNCC(MAX_EXAMPLES_IN_MODEL, numOfPatches, CV_32FC1, ACCESS_RW, USAGE_ALLOCATE_DEVICE_MEMORY);
ocl::Kernel k;
ocl::ProgramSource src = ocl::tracking::tldDetector_oclsrc;
String error;
ocl::Program prog(src, String(), error);
k.create("batchNCC", prog);
if (k.empty())
printf("Kernel create failed!!!\n");
k.args(
ocl::KernelArg::PtrReadOnly(devPatches),
ocl::KernelArg::PtrReadOnly(devPositiveSamples),
ocl::KernelArg::PtrReadOnly(devNegativeSamples),
ocl::KernelArg::PtrWriteOnly(devPosNCC),
ocl::KernelArg::PtrWriteOnly(devNegNCC),
*posNum,
*negNum,
numOfPatches);
size_t globSize = 2 * numOfPatches*MAX_EXAMPLES_IN_MODEL;
if (!k.run(1, &globSize, NULL, true))
printf("Kernel Run Error!!!");
Mat posNCC = devPosNCC.getMat(ACCESS_READ);
Mat negNCC = devNegNCC.getMat(ACCESS_READ);
//Calculate Srs
for (int id = 0; id < numOfPatches; id++)
{
double spr = 0.0, smr = 0.0, spc = 0.0, smc = 0;
int med = getMedian((*timeStampsPositive));
for (int i = 0; i < *posNum; i++)
{
spr = std::max(spr, 0.5 * (posNCC.at<float>(id * 500 + i) + 1.0));
if ((int)(*timeStampsPositive)[i] <= med)
spc = std::max(spr, 0.5 * (posNCC.at<float>(id * 500 + i) + 1.0));
}
for (int i = 0; i < *negNum; i++)
smc = smr = std::max(smr, 0.5 * (negNCC.at<float>(id * 500 + i) + 1.0));
if (spr + smr == 0.0)
resultSr[id] = 0.0;
else
resultSr[id] = spr / (smr + spr);
if (spc + smc == 0.0)
resultSc[id] = 0.0;
else
resultSc[id] = spc / (smc + spc);
}
}
示例4: make
static Program make(void)
{
Program prog(ObjectDesc("Flare"));
prog.AttachShader(FlareVertShader());
prog.AttachShader(FlareGeomShader());
prog.AttachShader(FlareFragShader());
prog.Link().Use();
return prog;
}
示例5: prog
void CreateProgPage::setPercent(uint32 per)
{
gcWString prog(L"{0} %", per);
m_labPercent->SetLabel(prog);
m_pbProgress->setProgress(per);
m_butPause->Enable(true);
Refresh(false);
}
示例6: start
//base function
void start(){
current_line = 1;
var_count = 0;
pro_count = 0;
advance();
prog();
write_var();
write_pro();
}
示例7: doWhen
// (when 'any . prg) -> any
any doWhen(any x) {
any a;
x = cdr(x);
if (isNil(a = EVAL(car(x))))
return Nil;
val(At) = a;
return prog(cdr(x));
}
示例8: powf
void SurfacePointsRenderer::Render(const Scene &scene) {
// Declare shared variables for Poisson point generation
BBox octBounds = scene.WorldBound();
octBounds.Expand(.001f * powf(octBounds.Volume(), 1.f/3.f));
Octree<SurfacePoint> pointOctree(octBounds);
// Create scene bounding sphere to catch rays that leave the scene
Point sceneCenter;
float sceneRadius;
scene.WorldBound().BoundingSphere(&sceneCenter, &sceneRadius);
Transform ObjectToWorld(Translate(sceneCenter - Point(0,0,0)));
Transform WorldToObject(Inverse(ObjectToWorld));
Reference<Shape> sph = new Sphere(&ObjectToWorld, &WorldToObject,
true, sceneRadius, -sceneRadius, sceneRadius, 360.f);
//Reference<Material> nullMaterial = Reference<Material>(NULL);
Material nullMaterial;
GeometricPrimitive sphere(sph, nullMaterial, NULL);
int maxFails = 2000, repeatedFails = 0, maxRepeatedFails = 0;
if (PbrtOptions.quickRender) maxFails = max(10, maxFails / 10);
int totalPathsTraced = 0, totalRaysTraced = 0, numPointsAdded = 0;
ProgressReporter prog(maxFails, "Depositing samples");
// Launch tasks to trace rays to find Poisson points
PBRT_SUBSURFACE_STARTED_RAYS_FOR_POINTS();
vector<Task *> tasks;
RWMutex *mutex = RWMutex::Create();
int nTasks = NumSystemCores();
for (int i = 0; i < nTasks; ++i)
tasks.push_back(new SurfacePointTask(scene, pCamera, time, i,
minDist, maxFails, *mutex, repeatedFails, maxRepeatedFails,
totalPathsTraced, totalRaysTraced, numPointsAdded, sphere, pointOctree,
points, prog));
EnqueueTasks(tasks);
WaitForAllTasks();
for (uint32_t i = 0; i < tasks.size(); ++i)
delete tasks[i];
RWMutex::Destroy(mutex);
prog.Done();
PBRT_SUBSURFACE_FINISHED_RAYS_FOR_POINTS(totalRaysTraced, numPointsAdded);
if (filename != "") {
// Write surface points to file
FILE *f = fopen(filename.c_str(), "w");
if (!f) {
Error("Unable to open output file \"%s\" (%s)", filename.c_str(),
strerror(errno));
return;
}
fprintf(f, "# points generated by SurfacePointsRenderer\n");
fprintf(f, "# position (x,y,z), normal (x,y,z), area, rayEpsilon\n");
for (u_int i = 0; i < points.size(); ++i) {
const SurfacePoint &sp = points[i];
fprintf(f, "%g %g %g %g %g %g %g %g\n", sp.p.x, sp.p.y, sp.p.z,
sp.n.x, sp.n.y, sp.n.z, sp.area, sp.rayEpsilon);
}
fclose(f);
}
}
示例9: ShapeProgram
ShapeProgram(void)
: Program(make())
, projection_matrix(prog(), "ProjectionMatrix")
, camera_matrix(prog(), "CameraMatrix")
, model_matrix(prog(), "ModelMatrix")
, camera_position(prog(), "CameraPosition")
, light_position(prog(), "LightPosition")
, color_1(prog(), "Color1")
, color_2(prog(), "Color2")
, metal_tex(prog(), "MetalTex")
{ }
示例10: TransformProgram
TransformProgram(void)
: Program(make())
, camera_matrix(prog(), "CameraMatrix")
, model_matrix(prog(), "ModelMatrix")
, light_proj_matrix(prog(), "LightProjMatrix")
, texture_matrix(prog(), "TextureMatrix")
, camera_position(prog(), "CameraPosition")
, light_position(prog(), "LightPosition")
, clip_plane(prog(), "ClipPlane")
, clip_direction(prog(), "ClipDirection")
{ }
示例11: build_with_source
/**
* In case BOOST_COMPUTE_USE_OFFLINE_CACHE macro is defined,
* the compiled binary is stored for reuse in the offline cache located in
* $HOME/.boost_compute on UNIX-like systems and in %APPDATA%/boost_compute
* on Windows.
*/
static program build_with_source(
const std::string &source,
const context &context,
const std::string &options = std::string()
)
{
#ifdef BOOST_COMPUTE_USE_OFFLINE_CACHE
// Get hash string for the kernel.
device d = context.get_device();
platform p = d.platform();
detail::sha1 hash;
hash.process( p.name() )
.process( p.version() )
.process( d.name() )
.process( options )
.process( source )
;
std::string hash_string = hash;
// Try to get cached program binaries:
try {
boost::optional<program> prog = load_program_binary(hash_string, context);
if (prog) {
prog->build(options);
return *prog;
}
} catch (...) {
// Something bad happened. Fallback to normal compilation.
}
// Cache is apparently not available. Just compile the sources.
#endif
const char *source_string = source.c_str();
cl_int error = 0;
cl_program program_ = clCreateProgramWithSource(context,
uint_(1),
&source_string,
0,
&error);
if(!program_){
BOOST_THROW_EXCEPTION(opencl_error(error));
}
program prog(program_, false);
prog.build(options);
#ifdef BOOST_COMPUTE_USE_OFFLINE_CACHE
// Save program binaries for future reuse.
save_program_binary(hash_string, prog);
#endif
return prog;
}
示例12: doIf
// (if 'any1 'any2 . prg) -> any
any doIf(any x) {
any a;
x = cdr(x);
if (isNil(a = EVAL(car(x))))
return prog(cddr(x));
val(At) = a;
x = cdr(x);
return EVAL(car(x));
}
示例13: doNond
// (nond ('any1 . prg1) ('any2 . prg2) ..) -> any
any doNond(any x) {
any a;
while (isCell(x = cdr(x))) {
if (isNil(a = EVAL(caar(x))))
return prog(cdar(x));
val(At) = a;
}
return Nil;
}
示例14: doUnless
// (unless 'any . prg) -> any
any doUnless(any x) {
any a;
x = cdr(x);
if (!isNil(a = EVAL(car(x)))) {
val(At) = a;
return Nil;
}
return prog(cdr(x));
}
示例15: prog
void Parser::parse() {
lookahead_ = scanner_.nextToken(attribute_, lineno_);
try {
prog();
} catch(const std::exception& error) {
std::stringstream ss;
ss << lineno_ << ": " << error.what();
throw std::runtime_error(ss.str());
}
}