本文整理汇总了C++中roundUp函数的典型用法代码示例。如果您正苦于以下问题:C++ roundUp函数的具体用法?C++ roundUp怎么用?C++ roundUp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了roundUp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: log
void ToneMappingDrago03::toneMapping_Drago03(Image<float> *img, float *avLum, float *maxLum, unsigned int *pic, float bias)
{
image = img;
picture = pic;
avLuminance = avLum;
maxLuminance = maxLum;
normMaxLum = *maxLum / *avLum; // normalize maximum luminance by average luminance
const float LOG05 = -0.693147f; // log(0.5)
divider = log10(normMaxLum + 1.0f);
biasP = log(bias)/LOG05;
logFile("divider = %f biasP = %f \n", divider, biasP);
localWorkSize[0] = BLOCK_SIZE;
localWorkSize[1] = BLOCK_SIZE;
//round values on upper value
logFile("%d %d \n", image->getHeight(), image->getWidth());
globalWorkSize[0] = roundUp(BLOCK_SIZE, image->getHeight());
globalWorkSize[1] = roundUp(BLOCK_SIZE, image->getWidth());
//core->runComputeUnit();
CStopWatch timer;
timer.startTimer();
calctoneMapping_Drago03CPU();
timer.stopTimer();
logFile("ToneMappingCPU,calc_time, , ,%f, \n", timer.getElapsedTime());
}
示例2: displayAll
/*
Similar to displayAll(), but only prints out folders and the size of those folders
Also recursively enters sub-directories
*/
void displayFolders(DIR *directory, char *path, long *total, int depth, int human) {
char *temp = malloc(sizeof(char) * MAX_LEN);
char *curPath = malloc(sizeof(char) * MAX_LEN);
struct dirent *tempdir = malloc(sizeof(struct dirent));
struct stat *stats = malloc(sizeof(struct stat));
if (directory) {
while ((tempdir = readdir(directory))) {
if ((path == NULL) && checkDir(tempdir->d_name) && strcmp(tempdir->d_name, "..") != 0 &&
strcmp(tempdir->d_name, ".") != 0)
sprintf(curPath, "./%s", tempdir->d_name);
else if (checkDir(tempdir->d_name) && strcmp(tempdir->d_name, "..") != 0 &&
strcmp(tempdir->d_name, ".") != 0)
sprintf(curPath, "%s/%s", path, tempdir->d_name);
if (checkDir(tempdir->d_name) && strcmp(tempdir->d_name, "..") != 0 &&
strcmp(tempdir->d_name, ".") != 0 && depth > 0) {
sprintf(temp, "./%s", tempdir->d_name);
chdir(tempdir->d_name);
displayFolders(opendir("."), curPath, total, depth - 1, human);
chdir("..");
lstat(tempdir->d_name, stats);
*total += roundUp((stats->st_size + (BLOCKSIZE - 1)) / BLOCKSIZE);
if (!human)
printf("%d\t%s\n", roundUp((int)(stats->st_size + (BLOCKSIZE - 1)) / BLOCKSIZE), curPath);
if (human)
printHuman(stats, -1, curPath);
}
}
}
}
示例3: roundUp
void DateTimeNumericFieldElement::stepUp() {
int newValue = roundUp(m_hasValue ? m_value + 1 : defaultValueForStepUp());
if (!m_range.isInRange(newValue))
newValue = roundUp(m_range.minimum);
m_typeAheadBuffer.clear();
setValueAsInteger(newValue, DispatchEvent);
}
示例4: srand
void Draft::startDraft(Team *arr, vector<NodeData*>& a, int nTeams, WINDOW **board){
int pickN, round = 0;
srand(time(0));
roundUp(++round, board[34]);
while(round < 16){
pickN = 0;
for(int i = 0; i < nTeams; i++){
if(arr[i].getUser()){
pick(arr[i], a, board, pickN);
}
else if(!arr[i].getUser()){
autoP(arr[i], a, board, pickN);
}
pickN++;
}
roundUp(++round, board[34]);
for(int i = (nTeams - 1); i > -1; i--){
if(arr[i].getUser())
pick(arr[i], a, board, pickN);
else if(!arr[i].getUser())
autoP(arr[i], a, board, pickN);
pickN++;
}
roundUp(++round, board[34]);
clearBoard(board);
}
}
示例5: clEnqueueAcquireGLObjects
void FDMHeatWidget::updateSystemTexture()
{
cl_int error;
error= clEnqueueAcquireGLObjects(clQueue, 1, &textureMem, 0, 0, 0);
if(checkError(error, "clEnqueueAcquireGLObjects"))
return;
// Work group y NDRange de renderKernel
size_t workGroupSize[2] = { 16, 16 };
size_t ndRangeSize[2];
ndRangeSize[0]= roundUp(system->getWidth(), workGroupSize[0]);
ndRangeSize[1]= roundUp(system->getHeight(), workGroupSize[1]);
bool suspended= system->isSuspended();
if(!suspended)
system->suspend();
// Ejecutamos el kernel para renderizar el sistema en una imagen
cl_mem systemData= system->getOutputData();
error = clSetKernelArg(renderKernel, 0, sizeof(cl_mem), (void*)&systemData);
error |= clSetKernelArg(renderKernel, 1, sizeof(cl_mem), (void*)&textureMem);
error |= clSetKernelArg(renderKernel, 2, sizeof(cl_mem), (void*)&paletteMem);
error |= clEnqueueNDRangeKernel(clQueue, renderKernel, 2, NULL, ndRangeSize, workGroupSize, 0, NULL, NULL);
checkError(error, "FDMHeatWidget::updateSystemTexture: clEnqueueNDRangeKernel");
if(!suspended)
system->resume();
error= clEnqueueReleaseGLObjects(clQueue, 1, &textureMem, 0, 0, 0);
if (checkError(error, "clEnqueueReleaseGLObjects"))
return;
}
示例6: roundUp
void Resistor::moveResistor(int x, int y, bool stepMode) {
if (stepMode) {
rPos.x = roundUp(x);
rPos.y = roundUp(y);
}
else {
rPos.x = x;
rPos.y = y;
}
}
示例7: mm_initialize
/**
* Sets up memory location
*/
void mm_initialize(u32int initrd_location){
initrd_location = initrd_location;
//Get the memory map from the multiboot_info
multiboot_memory_map_t* mmap = (multiboot_memory_map_t*)mbt->mmap_addr;
//loop through the memory map for a usable (1) portion that is bigger than 0x1000000
while((u32int)mmap < (mbt->mmap_addr + mbt->mmap_length)) {
if(mmap->type == 1 && mmap->len > 0x1000000){
//if found, save that memLoc and memAmt for later use
memLoc = /*(u32int*)*/mmap->addr;
memAmt = mmap->len;
}
mmap = (multiboot_memory_map_t*) ( (unsigned int)mmap + mmap->size + sizeof(mmap->size) );
// mmap = (multiboot_memory_map_t) ( (unsigned int)mmap + mmap.size + sizeof(mmap.size) );
}
/* Calculate the initrd (ramdisk size) */
initrd_end = *(u32int*)(mbt->mods_addr+4);
initrd_size = initrd_end - initrd_location;
/* Only used to display the start location of Ram, then promptly forgotten */
u32int startOfRam = memLoc;
/* Calculate a pointer to the end of physical memory. */
memEndLoc = memLoc + memAmt;
/* Add the size of the kernel to memLoc at the nearest 4kb boundry */
memLoc += roundUp(end - code, 4096);
/* Add the size of the initrd to memLoc at the nearest 4kb boundry */
memLoc += roundUp(initrd_size, 4096);
/* Calculate the amount of memory that is usable for heap allocation after kernel*/
memUsable = memEndLoc - memLoc;
printf("\nEnd of Kernel : 0x%x", (u32int) end);
printf("\nStart of Kernel : 0x%x", (u32int) code);
printf("\nSize of Kernel : 0x%x", (u32int)(end - code));
printf("\nMemory Found At Location: 0x%x", (u32int) startOfRam);
printf("\nMemory Amount Located : 0x%x", memAmt);
printf("\nEnd of Physical Memory : 0x%x", (u32int) memEndLoc);
printf("\nInitrd Starts At : 0x%x", initrd_location);
printf("\nInitrd Ends At : 0x%x", initrd_end);
printf("\nInitrd Size : 0x%x", initrd_size);
printf("\nUsable Memory Starts At: 0x%x", (u32int) memLoc);
printf("\nUsable Amount of Memory: 0x%x", memUsable);
placement_address = (u32int)memLoc;
//while(1);
}
示例8: loadTextureDecal
gliGenericImage *
loadTextureDecal(gliGenericImage *image, int mipmap)
{
int needsScaling;
int nw, nh;
nw = roundUp(image->width);
nh = roundUp(image->height);
if ((nw != image->width) || (nh != image->height)) {
needsScaling = 1;
} else {
needsScaling = 0;
}
assert(image->format != GL_COLOR_INDEX);
if (needsScaling) {
gliGenericImage *nimage;
nimage = gliScaleImage(image, nw, nh);
gliFree(image);
image = nimage;
}
#ifdef __APPLE__
mipmap = 0; /* Why doesn't Apple's gluBuild2DMipmaps work correctly? */
#endif
if (mipmap) {
GLint status;
glTexParameteri(GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
status = gluBuild2DMipmaps(GL_TEXTURE_2D, image->internalFormat,
nw, nh, image->format, image->type, image->pixels);
if (status == GLU_INVALID_ENUM) {
gliConvertImageToCoreFormat(image);
status = gluBuild2DMipmaps(GL_TEXTURE_2D, image->internalFormat,
nw, nh, image->format, image->type, image->pixels);
}
assert(status == 0);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, image->internalFormat,
nw, nh, 0,
image->format, image->type, image->pixels);
}
return image;
}
示例9: roundUp
//--------------------------------------------------------------
void SalsaScreen::setup()
{
mainWindowWidth = config.mainWindowWidth;
player.loadSound("sounds/Salsa_instructions.mp3");
player.setVolume(0.75f);
player.setMultiPlay(false);
intervall1 = 800; // in ms
intervall1 = roundUp(intervall1/100);
intervall2 = 500; // quicker
intervall2 = roundUp(intervall2/100);
startPlayerPos_R1 = 20800; // individual
stopPlayerPos_R1 = 39800;
startPlayerPos_R2 = 47500; // move forwards
stopPlayerPos_R2 = 66599;
startPlayerPos_R3 = 66600; // partner
stopPlayerPos_R3 = 92900;
startPlayerPos_R4 = 92901; // faster
stopPlayerPos_R4 = 115900;
startPlayerPos_R1 = roundUp(startPlayerPos_R1 /100);
stopPlayerPos_R1 = roundUp(stopPlayerPos_R1 /100);
startPlayerPos_R2 = roundUp(startPlayerPos_R2 /100);
stopPlayerPos_R2 = roundUp(stopPlayerPos_R2 /100);
startPlayerPos_R3 = roundUp(startPlayerPos_R3 /100);
stopPlayerPos_R3 = roundUp(stopPlayerPos_R3 /100);
startPlayerPos_R4 = roundUp(startPlayerPos_R4 /100);
stopPlayerPos_R4 = roundUp(stopPlayerPos_R4 /100);
prevPlayerPos = startPlayerPos_R1;
// CHOREOGRAPHY --------------------------------------------
currentStep = 0;
isStart = true;
boxWidth = 0;
boxHeight = 300;
role = salsaChoreo.init(0, 0, boxWidth, boxHeight, "Salsa");
// position of each couple
cX1 = config.mainWindowWidth/4-boxHeight/3;
cY1 = config.mainWindowHeight/4;
cX2 = config.mainWindowWidth*3/4-boxHeight+boxHeight/3;
cY2 = config.mainWindowHeight*3/4;
// lift icon - resize
newIconSize = config.iconSize;
biconWasBig = false;
}
示例10: glFinish
void GLWidget::runKernel()
{
cl_int error;
// block until all gl functions are completed
glFinish();
// Le doy a OpenCL el vbo que estaba usando OpenGL para renderizar
error = clEnqueueAcquireGLObjects(clQueue, 1, &clvbo, 0, 0, 0);
if (checkError(error, "clEnqueueAcquireGLObjects")) {
return;
}
localWorkSize = 1024;
globalWorkSize = roundUp(vertexNumber, localWorkSize);
error = clEnqueueNDRangeKernel(clQueue, clKernel, 1, NULL, &globalWorkSize, &localWorkSize, 0, 0, 0);
if (checkError(error, "clEnqueueNDRangeKernel")) {
return;
}
// unmap buffer object
error = clEnqueueReleaseGLObjects(clQueue, 1, &clvbo, 0, 0, 0);
if (checkError(error, "clEnqueueReleaseGLObjects")) {
return;
}
clFinish(clQueue);
}
示例11: calcNrThreads
static void
calcNrThreads(
size_t threads[2],
const SubproblemDim *subdims,
const PGranularity *pgran,
const void *args,
const void *extra)
{
size_t yLen; /* Length of "Y" vector */
const CLBlasKargs *kargs = args;
unsigned int subgr = pgran->wgSize[0] / (subdims[0].bwidth / subdims[1].bwidth);
(void)subdims;
(void)extra;
yLen = kargs->transA == clblasNoTrans ? kargs->M : kargs->N;
if (yLen == 0) {
yLen = 1;
//launch one group to avoid CL_INVALID_WORK_GROUP_SIZE error
}
//each work item handles y1 lines
threads[0] = divRoundUp(yLen, subdims[1].y) * subgr;
threads[0] = roundUp(threads[0], pgran->wgSize[0]);
threads[1] = 0;
}
示例12: find
void find(double* ptr, size_t size, double& min, double &max)
{
size_t num_wg = 64;
size_t num_compute_units = 6;
size_t workgroup_size = 256;
size_t global_size = num_wg * num_compute_units;
m_result_min.resize( global_size);
m_result_max.resize( global_size);
m_args.p_values = ptr;
m_args.size = size;
m_args.p_min_list = &m_result_min[0];
m_args.p_max_list = &m_result_max[0];
hsa_signal_t signal;
Launch_params_t lp {.ndim=1, .gdims={std::min(roundUp(size, workgroup_size), global_size*workgroup_size)}, .ldims={workgroup_size}};
m_dispatch->dispatchKernel(m_args, signal, lp);
m_dispatch->waitComplete(signal);
if (size < workgroup_size)
{
min = ptr[ m_result_min[0]];
max = ptr[ m_result_max[0]];
}
return reduce(ptr, size, min,max);
}
protected:
示例13: kma_free
void kma_free(void* ptr, kma_size_t size)
{
size = roundUp(size);
kma_page_t *page = *((kma_page_t **) BASEADDR(ptr));
if (diff(size) == 8) { //if 8196, free the page
free_page(page);
PAGE_COUNT--;
} else {
page->size += size;
if (page->size == PAGESIZE - sizeof(kma_page_t*)) {
derefPage(page->ptr, size); //if page is made of free buffers, derefence the buffer in freelist
free_page(page);
PAGE_COUNT--;
} else { //not all free, give the buffer back to freelist
insertAtHead(ptr, size);
}
}
//free everything
if(PAGE_COUNT == 1) {
free_page(FREEPAGE);
INIT = FALSE;
PAGE_COUNT = 0;
FREE_LIST_HEAD = NULL;
}
}
示例14: assert
//------------------------------------------------------------------------
// ArenaAllocator::alloateMemory:
// Allocates memory using an `ArenaAllocator`.
//
// Arguments:
// size - The number of bytes to allocate.
//
// Return Value:
// A pointer to the allocated memory.
//
// Note:
// This is the DEBUG-only version of `allocateMemory`; the release
// version of this method is defined in the corresponding header file.
// This version of the method has some abilities that the release
// version does not: it may inject faults into the allocator and
// seeds all allocations with a specified pattern to help catch
// use-before-init problems.
void* ArenaAllocator::allocateMemory(size_t size)
{
assert(size != 0 && (size & (sizeof(int) - 1)) == 0);
// Ensure that we always allocate in pointer sized increments.
size = (size_t)roundUp(size, sizeof(size_t));
if (JitConfig.ShouldInjectFault() != 0)
{
// Force the underlying memory allocator (either the OS or the CLR hoster)
// to allocate the memory. Any fault injection will kick in.
void* p = ClrAllocInProcessHeap(0, S_SIZE_T(1));
if (p != nullptr)
{
ClrFreeInProcessHeap(0, p);
}
else
{
NOMEM(); // Throw!
}
}
void* block = m_nextFreeByte;
m_nextFreeByte += size;
if (m_nextFreeByte > m_lastFreeByte)
{
block = allocateNewPage(size);
}
memset(block, UninitializedWord<char>(), size);
return block;
}
示例15: transform
double transform(double* ptr, size_t size)
{
size_t num_wg = 64;
size_t num_compute_units = 6;
size_t global_size = num_wg * num_compute_units;
size_t workgroup_size = 256;
m_result.resize( global_size);
m_local_dispatch->clearArgs();
FIX_ARGS_STABLE(m_local_dispatch);
m_local_dispatch->pushPointerArg((void*)ptr);
m_local_dispatch->pushIntArg((int)size );
m_local_dispatch->pushPointerArg((void*)&m_result[0]);
size_t global_dims[3] = { std::min(roundUp(size, workgroup_size), global_size*workgroup_size),1,1};
size_t local_dims[3] = {workgroup_size,1,1};
m_local_dispatch->setLaunchAttributes(1, global_dims, local_dims);
m_local_dispatch->dispatchKernelWaitComplete();
if (size < workgroup_size)
{
return m_result[0];
}
return reduceTail(size);
}