示例#1
0
std::vector<DebugInfo::InfoGroup> DebugInfo::collectObjectInfo()
{
	m_infoGroups.clear();
	m_memoryUsage.clear();

    for (Object * object: ObjectRegistry::current().objects())
	{
		visit(object);
	}

	std::vector<InfoGroup> groups;

	InfoGroup overview;
	overview.name = "Overview";
	InfoUnit memory;
	memory.name = "Memory Usage";
	unsigned total = 0;
	for (const std::pair<std::string, unsigned>& pair: m_memoryUsage)
	{
		memory.addProperty(pair.first, humanReadableSize(pair.second));
		total += pair.second;
	}
	memory.addProperty("Total", humanReadableSize(total));
	overview.addInfoUnit(memory);

	groups.push_back(overview);


	for (const std::pair<std::string, InfoGroup>& pair: m_infoGroups)
	{
		groups.push_back(pair.second);
	}

	return groups;
}
示例#2
0
void DebugInfo::visitRenderBufferObject(Renderbuffer* rbo)
{
    assert(rbo != nullptr);

	InfoUnit info;
	info.name = name("RenderBufferObject", rbo);

	int w = rbo->getParameter(gl::GL_RENDERBUFFER_WIDTH);
	int h = rbo->getParameter(gl::GL_RENDERBUFFER_HEIGHT);

	int r = rbo->getParameter(gl::GL_RENDERBUFFER_RED_SIZE);
	int g = rbo->getParameter(gl::GL_RENDERBUFFER_GREEN_SIZE);
	int b = rbo->getParameter(gl::GL_RENDERBUFFER_BLUE_SIZE);
	int a = rbo->getParameter(gl::GL_RENDERBUFFER_ALPHA_SIZE);

	int d = rbo->getParameter(gl::GL_RENDERBUFFER_DEPTH_SIZE);
	int s = rbo->getParameter(gl::GL_RENDERBUFFER_STENCIL_SIZE);

	int memory = (int)std::ceil((w*h*(r+g+b+a+d+s))/8.0);

	m_memoryUsage["RenderBufferObjects"] += memory;
	info.addProperty("memory", humanReadableSize(memory));
	info.addProperty("size", std::to_string(w)+" x "+std::to_string(h));

	addInfo("RenderBufferObjects", info);
}
示例#3
0
std::vector<DebugInfo::InfoGroup> DebugInfo::generalInfo()
{
	InfoGroup generalGroup;

	InfoUnit generalInfo;
	InfoUnit memoryInfo;
	InfoUnit textureInfo;

	generalGroup.name = "General";

	generalInfo.name = "OpenGL";
	memoryInfo.name = "Memory";
	textureInfo.name = "General Texture Info";

    generalInfo.addProperty("version", versionString());
    generalInfo.addProperty("vendor", vendor());
    generalInfo.addProperty("renderer", renderer());
    generalInfo.addProperty("core profile", isCoreProfile()?"true":"false");
    generalInfo.addProperty("GLSL version", getString(gl::GL_SHADING_LANGUAGE_VERSION));

	memoryInfo.addProperty("total", humanReadableSize(1024ll*memory::total()));
	memoryInfo.addProperty("dedicated", humanReadableSize(1024ll*memory::dedicated()));
	memoryInfo.addProperty("available", humanReadableSize(1024ll*memory::available()));
	memoryInfo.addProperty("evicted", humanReadableSize(1024ll*memory::evicted()));
	memoryInfo.addProperty("evictionCount", memory::evictionCount());

    int maxTextureSize = getInteger(gl::GL_MAX_TEXTURE_SIZE);
	textureInfo.addProperty("Max Texture Size", std::to_string(maxTextureSize)+" x "+std::to_string(maxTextureSize));
    textureInfo.addProperty("Max Vertex Texture Image Units", getInteger(gl::GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS));
    textureInfo.addProperty("Max Texture Image Units", getInteger(gl::GL_MAX_IMAGE_UNITS));
    textureInfo.addProperty("Max Geometry Texture Units", getInteger(gl::GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS));
    auto maxViewportSize = getIntegers<2>(gl::GL_MAX_VIEWPORT_DIMS);
	textureInfo.addProperty("Max viewport size", std::to_string(maxViewportSize[0])+" x "+std::to_string(maxViewportSize[1]));
    textureInfo.addProperty("Max clip distances", getInteger(gl::GL_MAX_CLIP_DISTANCES));
    textureInfo.addProperty("Max Samples", getInteger(gl::GL_MAX_SAMPLES));

	generalGroup.addInfoUnit(generalInfo);
	generalGroup.addInfoUnit(memoryInfo);
	generalGroup.addInfoUnit(textureInfo);

	return std::vector<InfoGroup>({ generalGroup });
}
示例#4
0
void DebugInfo::visitBuffer(Buffer* buffer)
{
    assert(buffer != nullptr);

	InfoUnit info;
	info.name = name("Buffer", buffer);

    gl::GLint memory = buffer->getParameter(gl::GL_BUFFER_SIZE);
	m_memoryUsage["Buffers"] += memory;
	info.addProperty("memory", humanReadableSize(memory));

	addInfo("Buffers", info);
}
示例#5
0
void DebugInfo::visitTexture(Texture* texture)
{
    assert(texture != nullptr);

	InfoUnit info;
	info.name = name("Texture", texture);

    int maxTextureSize = getInteger(gl::GL_MAX_TEXTURE_SIZE);
	int maxLevels = (int)std::ceil(std::log(maxTextureSize)/std::log(2))+1;

    if (texture->target() == gl::GL_TEXTURE_CUBE_MAP)
    {
        info.addProperty("size", "cubemap size computation not implemented yet");
    }
    else
    {
        int memory = 0;
        for (int i = 0; i<=maxLevels; ++i)
        {
            if (texture->getLevelParameter(i, gl::GL_TEXTURE_COMPRESSED) == static_cast<gl::GLint>(gl::GL_TRUE))
            {
                memory += texture->getLevelParameter(i, gl::GL_TEXTURE_COMPRESSED_IMAGE_SIZE);
            }
            else
            {
                int w = texture->getLevelParameter(i, gl::GL_TEXTURE_WIDTH);
                int h = texture->getLevelParameter(i, gl::GL_TEXTURE_HEIGHT);
                int d = texture->getLevelParameter(i, gl::GL_TEXTURE_DEPTH);

                int r = texture->getLevelParameter(i, gl::GL_TEXTURE_RED_SIZE);
                int g = texture->getLevelParameter(i, gl::GL_TEXTURE_GREEN_SIZE);
                int b = texture->getLevelParameter(i, gl::GL_TEXTURE_BLUE_SIZE);
                int a = texture->getLevelParameter(i, gl::GL_TEXTURE_ALPHA_SIZE);
                int ds = texture->getLevelParameter(i, gl::GL_TEXTURE_DEPTH_SIZE);

                memory += (int)std::ceil((w*h*d*(r+g+b+a+ds))/8.0);
            }
        }

        m_memoryUsage["Textures"] += memory;
        info.addProperty("memory", humanReadableSize(memory));
        info.addProperty("size", std::to_string(texture->getLevelParameter(0, gl::GL_TEXTURE_WIDTH))+" x "+std::to_string(texture->getLevelParameter(0, gl::GL_TEXTURE_HEIGHT)));
    }

	addInfo("Textures", info);
}
示例#6
0
void DebugInfo::visitProgram(Program* program)
{
    assert(program != nullptr);

	InfoUnit info;
	info.name = name("Program", program);

    gl::GLint memory = program->get(gl::GL_PROGRAM_BINARY_LENGTH);
	m_memoryUsage["Programs"] += memory;
	info.addProperty("memory", humanReadableSize(memory));

	int i = 0;
	for (Shader* shader: program->shaders())
	{
		info.addProperty("Shader "+std::to_string(i++), name("Shader", shader));
	}

	addInfo("Programs", info);
}
示例#7
0
文件: d8.cpp 项目: kornholi/TauDEM
//Open files, Initialize grid memory, makes function calls to set flowDir, slope, and resolvflats, writes files
int setdird8(char* demfile, char* pointfile, char *slopefile, char *flowfile, int useflowfile)
{
    MPI_Init(NULL,NULL);

    int rank,size;
    MPI_Comm_rank(MCW,&rank);
    MPI_Comm_size(MCW,&size);

    if (rank==0) {
        printf("D8FlowDir version %s\n",TDVERSION);

        if (strlen(pointfile) == 0) {
            printf("WARNING: no output p file specified\n");
        }

        if (strlen(slopefile) == 0) {
            printf("WARNING: no output sd8 file specified\n");
        }

        fflush(stdout);
    }

    MPITimer t;

    t.start("Total");
    t.start("Header read");

    //Read DEM from file
    tiffIO dem(demfile, FLOAT_TYPE);

    long totalX = dem.getTotalX();
    long totalY = dem.getTotalY();
    double dx = dem.getdxA();
    double dy = dem.getdyA();

    linearpart<float> elevDEM(totalX, totalY, dx, dy, MPI_FLOAT, *(float*) dem.getNodata());

    int xstart, ystart;
    int nx = elevDEM.getnx();
    int ny = elevDEM.getny();
    elevDEM.localToGlobal(0, 0, xstart, ystart);
    elevDEM.savedxdyc(dem);

    t.end("Header read");

    if (rank==0) {
        float timeestimate=(2.8e-9*pow((double)(totalX*totalY),1.55)/pow((double) size,0.65))/60+1;  // Time estimate in minutes
        //fprintf(stderr,"%d %d %d\n",totalX,totalY,size);
        fprintf(stderr,"This run may take on the order of %.0f minutes to complete.\n",timeestimate);
        fprintf(stderr,"This estimate is very approximate. \nRun time is highly uncertain as it depends on the complexity of the input data \nand speed and memory of the computer. This estimate is based on our testing on \na dual quad core Dell Xeon E5405 2.0GHz PC with 16GB RAM.\n");
        fflush(stderr);
    }

    uint64_t bytes_to_read = (uint64_t) nx * ny * sizeof(float);
    if (rank == 0) { 
        fprintf(stderr, "Reading input data (%s)... ", humanReadableSize(bytes_to_read).c_str());
    }

    t.start("Data read");

    dem.read(xstart, ystart, ny, nx, elevDEM.getGridPointer(), elevDEM.getGridPointerStride());
    elevDEM.share();
    double data_read_time = t.end("Data read");
   
    if (rank == 0) {
        fprintf(stderr, "done (%s/s).\n", humanReadableSize(bytes_to_read / data_read_time).c_str());
    }

    //Creates empty partition to store new flow direction
    short flowDirNodata = MISSINGSHORT;

    linearpart<short> flowDir(totalX, totalY, dx, dy, MPI_SHORT, flowDirNodata);

    //If using a flowfile, read it in
    if (useflowfile == 1) {
        tiffIO flow(flowfile, SHORT_TYPE);

        linearpart<short> imposedflow(flow.getTotalX(), flow.getTotalY(),
                flow.getdxA(), flow.getdyA(), MPI_SHORT, *(short*) flow.getNodata());

        if (!dem.compareTiff(flow)) {
            printf("Error using imposed flow file.\n");
            return 1;
        }

        for (int j=0; j < elevDEM.getny(); j++) {
            for (int i=0; i < elevDEM.getnx(); i++ ) {
                short data = imposedflow.getData(i,j);

                if (imposedflow.isNodata(i,j) || !imposedflow.hasAccess(i-1,j) || !imposedflow.hasAccess(i+1,j) ||
                        !imposedflow.hasAccess(i,j-1) || !imposedflow.hasAccess(i,j+1)) {
                    //Do nothing
                } else if (data > 0 && data <= 8) {
                    flowDir.setData(i,j,data);
                }
            }
        }
    }

    if (rank == 0) fprintf(stderr, "Calculating flow directions... ");
    t.start("Calculate flow directions");
    uint64_t numFlat = setPosDir(elevDEM, flowDir);
    t.end("Calculate flow directions");
  
    flowDir.share();

    if (strlen(slopefile) > 0)
    {
        t.start("Calculate slope");
        
        //Creates empty partition to store new slopes
        float slopeNodata = -1.0f;
        linearpart<float> slope(totalX, totalY, dx, dy, MPI_FLOAT, slopeNodata);

        calcSlope(flowDir, elevDEM, slope);

        t.end("Calculate slope");

        t.start("Write slope");
        tiffIO slopeIO(slopefile, FLOAT_TYPE, &slopeNodata, dem);
        slopeIO.write(xstart, ystart, ny, nx, slope.getGridPointer(), slope.getGridPointerStride());
        t.end("Write slope");
    }

    uint64_t totalNumFlat = 0;
    MPI_Allreduce(&numFlat, &totalNumFlat, 1, MPI_UINT64_T, MPI_SUM, MCW);
   
    if (rank == 0) {
        fprintf(stderr, "done. %" PRIu64 " flats to resolve.\n", totalNumFlat);
        fflush(stderr);
    }

    t.start("Resolve flats");

    if (totalNumFlat > 0) {
        if (rank == 0) {
            fprintf(stderr, "Finding flat islands...\n");
        }

        std::vector<std::vector<node>> islands;
        std::vector<std::vector<node>> borderingIslands;

        t.start("Find islands");
        findIslands<D8>(flowDir, islands, borderingIslands);
        t.end("Find islands");

        uint64_t localSharedFlats = 0, sharedFlats = 0;
        for (auto& island : borderingIslands) {
            localSharedFlats += island.size();
        }

        t.start("Resolve shared flats");
        MPI_Allreduce(&localSharedFlats, &sharedFlats, 1, MPI_UINT64_T, MPI_SUM, MCW);

        if (rank == 0 && size > 1) {
            fprintf(stderr, "Processing partial flats\n");

            printf("PRL: %llu flats shared across processors (%llu local -> %.2f%% shared)\n",
                    sharedFlats, totalNumFlat - sharedFlats, 100. * sharedFlats / totalNumFlat);
        }

        if (sharedFlats > 0) {
            SparsePartition<int> inc(totalX, totalY, 0);
            size_t lastNumFlat = resolveFlats_parallel_async<D8>(elevDEM, inc, flowDir, borderingIslands);

            if (rank==0) {
                fprintf(stderr, "PRL: Iteration complete. Number of flats remaining: %zu\n", lastNumFlat);
                fflush(stderr);
            }

            // Repeatedly call resolve flats until there is no change across all processors
            while (lastNumFlat > 0) {
                SparsePartition<int> newInc(totalX, totalY, 0);

                lastNumFlat = resolveFlats_parallel_async<D8>(inc, newInc, flowDir, borderingIslands);
                inc = std::move(newInc);

                if (rank==0) {
                    fprintf(stderr, "PRL: Iteration complete. Number of flats remaining: %zu\n", lastNumFlat);
                    fflush(stderr);
                }
            }
        }
        t.end("Resolve shared flats");

        //printf("rank %d: Done, %d islands. Took %.2f seconds\n", rank, numIslands, MPI_Wtime() - flatFindStart);
        //printf("rank %d: %lu bordering islands with %d flats\n", rank, bordering_islands.size(), localSharedFlats);

        t.start("Resolve local flats");
        if (!islands.empty()) {
            SparsePartition<int> inc(totalX, totalY, 0);
            size_t lastNumFlat = resolveFlats<D8>(elevDEM, inc, flowDir, islands);

            if (rank==0) {
                fprintf(stderr, "Iteration complete. Number of flats remaining: %zu\n\n", lastNumFlat);
                fflush(stderr);
            }

            // Repeatedly call resolve flats until there is no change
            while (lastNumFlat > 0)
            {
                SparsePartition<int> newInc(totalX, totalY, 0);

                lastNumFlat = resolveFlats<D8>(inc, newInc, flowDir, islands); 
                inc = std::move(newInc);

                if (rank==0) {
                    fprintf(stderr, "Iteration complete. Number of flats remaining: %zu\n\n", lastNumFlat);
                    fflush(stderr);
                }
            } 
        }
        t.end("Resolve local flats");
    }

    t.end("Resolve flats");

    if (strlen(pointfile) > 0) {
        t.start("Write directions");
        tiffIO pointIO(pointfile, SHORT_TYPE, &flowDirNodata, dem);
        pointIO.write(xstart, ystart, ny, nx, flowDir.getGridPointer(), flowDir.getGridPointerStride());
        t.end("Write directions");
    }

    t.end("Total");
    t.stop();
    //t.save("timing_info");

    MPI_Finalize();
    return 0;
}
示例#8
0
// Update the information labels in the bottom left corner of the dialog
// and switches the editor mode, if required, according to the detected data type.
void EditDialog::updateCellInfoAndMode(const QByteArray& data)
{
    QByteArray cellData = data;

    switchEditorMode(ui->buttonAutoSwitchMode->isChecked());

    // Image data needs special treatment
    if (dataType == Image || dataType == SVG) {
        QBuffer imageBuffer(&cellData);
        QImageReader imageReader(&imageBuffer);

        // Display the image format
        QString imageFormat = imageReader.format();

        ui->labelType->setText(tr("Type of data currently in cell: %1 Image").arg(imageFormat.toUpper()));

        // Display the image dimensions and size
        QSize imageDimensions = imageReader.size();
        int imageSize = cellData.size();

        QString labelSizeText = tr("%1x%2 pixel(s)").arg(imageDimensions.width()).arg(imageDimensions.height()) + ", " + humanReadableSize(imageSize);

        ui->labelSize->setText(labelSizeText);

        return;
    }

    // Use a switch statement for the other data types to keep things neat :)
    switch (dataType) {
    case Null:
        // NULL data type
        ui->labelType->setText(tr("Type of data currently in cell: NULL"));
        ui->labelSize->setText(tr("%n byte(s)", "", 0));
        ui->editorText->setStyleSheet("QTextEdit{ font-style: italic; }");
        ui->editorText->setPlaceholderText(Settings::getValue("databrowser", "null_text").toString());
        break;

    case Text: {
        // Text only
        // Determine the length of the cell text in characters (possibly different to number of bytes).
        int textLength = QString(cellData).length();
        ui->labelType->setText(tr("Type of data currently in cell: Text / Numeric"));
        ui->labelSize->setText(tr("%n char(s)", "", textLength));
        break;
    }
    case JSON: {
        // Valid JSON
        // Determine the length of the cell text in characters (possibly different to number of bytes).
        int jsonLength = QString(cellData).length();
        ui->labelType->setText(tr("Type of data currently in cell: Valid JSON"));
        ui->labelSize->setText(tr("%n char(s)", "", jsonLength));
        break;
    }
    default:

        // Determine the length of the cell data
        int dataLength = cellData.length();
        // If none of the above data types, consider it general binary data
        ui->labelType->setText(tr("Type of data currently in cell: Binary"));
        ui->labelSize->setText(tr("%n byte(s)", "", dataLength));
        break;
    }
}
示例#9
0
文件: elws.cpp 项目: Sektorka/ocs
QString ELWS::humanReadableBandwidth(quint64 bytesPerSecond)
{
  return humanReadableSize(bytesPerSecond) + QString("/s");
}