Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/ldyken53/TVCG-progiso
31 October 2024, 16:40:01 UTC
  • Code
  • Branches (3)
  • Releases (0)
  • Visits
Revision 9b4d063dbd517c8db6196fcfba97d7a4442af2c0 authored by Landon Dyken on 11 June 2024, 17:43:45 UTC, committed by Landon Dyken on 11 June 2024, 17:43:45 UTC
Handle all buffer management manually rather than automatically allocating with ONNX
1 parent 90a4a61
  • Files
  • Changes
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    • refs/heads/master
    • refs/heads/npm
    • 9b4d063dbd517c8db6196fcfba97d7a4442af2c0
    No releases to show
  • e9f1060
  • /
  • src
  • /
  • stream_compact.js
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
  • snapshot
origin badgerevision badge
swh:1:rev:9b4d063dbd517c8db6196fcfba97d7a4442af2c0
origin badgedirectory badge
swh:1:dir:9a5575fd388597f53212908dc146c18fc621d17e
origin badgecontent badge
swh:1:cnt:f14a0733b6926ceea3e779a8382dd42a46f9fcb5
origin badgesnapshot badge
swh:1:snp:6dbeb1fbe859f48945dd22bd530e60eb1a5ac9b6

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 9b4d063dbd517c8db6196fcfba97d7a4442af2c0 authored by Landon Dyken on 11 June 2024, 17:43:45 UTC
Handle all buffer management manually rather than automatically allocating with ONNX
Tip revision: 9b4d063
stream_compact.js
import { stream_compact_comp_spv, stream_compact_data_comp_spv } from "./embedded_shaders";
export var StreamCompact = function(device) {
    this.device = device;

    // Not sure how to query this limit, assuming this size based on OpenGL
    // In a less naive implementation doing some block-based implementation w/
    // larger group sizes might be better as well
    // We also need to make sure the offset we'll end up using for the
    // dynamic offsets is aligned to 256 bytes. We're offsetting into arrays
    // of uint32, so determine the max dispatch size we should use for each
    // individual aligned chunk
    this.maxDispatchSize = Math.floor(65535 / 256) * 256;

    this.streamCompactBGLayout = device.createBindGroupLayout({
        entries: [
            {
                binding: 0,
                visibility: GPUShaderStage.COMPUTE,
                buffer: {
                    type: "storage",
                }
            },
            {
                binding: 1,
                visibility: GPUShaderStage.COMPUTE,
                buffer: {
                    type: "storage",
                }
            },
            {
                binding: 2,
                visibility: GPUShaderStage.COMPUTE,
                buffer: {
                    type: "uniform",
                }
            },
            {
                binding: 3,
                visibility: GPUShaderStage.COMPUTE,
                buffer: {
                    type: "storage",
                }
            },
        ],
    });
    this.streamCompactPipeline = device.createComputePipeline({
        layout: device.createPipelineLayout({
            bindGroupLayouts: [this.streamCompactBGLayout],
        }),
        compute: {
            module: device.createShaderModule({code: stream_compact_comp_spv}),
            entryPoint: "main",
        },
    });

    this.dataBGLayout = device.createBindGroupLayout({
        entries: [{
            binding: 0,
            visibility: GPUShaderStage.COMPUTE,
            buffer: {
                type: "storage",
            }
        }]
    });
    this.streamCompactDataPipeline = device.createComputePipeline({
        layout: device.createPipelineLayout(
            {bindGroupLayouts: [this.streamCompactBGLayout, this.dataBGLayout]}),
        compute: {
            module: device.createShaderModule({code: stream_compact_data_comp_spv}),
            entryPoint: "main",
        }
    });
};

StreamCompact.prototype.compactActiveIDs =
    async function(numElements, isActiveBuffer, offsetsBuffer, outputBuffer) {
    // No push constants in the API? This is really a hassle to hack together
    // because I also have to obey (at least Dawn's rule is it part of the spec?)
    // that the dynamic offsets be 256b aligned
    // Please add push constants!
    var numChunks = Math.ceil(numElements / this.maxDispatchSize);
    var compactPassOffset = this.device.createBuffer({
        size: numChunks * 256,
        usage: GPUBufferUsage.UNIFORM,
        mappedAtCreation: true,
    });
    {
        var map = new Uint32Array(compactPassOffset.getMappedRange());
        for (var i = 0; i < numChunks; ++i) {
            map[i * 64] = i * this.maxDispatchSize;
        }
        compactPassOffset.unmap();
    }
    var commandEncoder = this.device.createCommandEncoder();
    var pass = commandEncoder.beginComputePass();
    pass.setPipeline(this.streamCompactPipeline);
    for (var i = 0; i < numChunks; ++i) {
        var numWorkGroups =
            Math.min(numElements - i * this.maxDispatchSize, this.maxDispatchSize);
        var offset = i * this.maxDispatchSize * 4;
        // Have to create bind groups here because dynamic offsets are not allowed
        // for security
        // TODO: Was this re-enabled?
        var streamCompactBG = null;
        if (numWorkGroups === this.maxDispatchSize) {
            streamCompactBG = this.device.createBindGroup({
                layout: this.streamCompactBGLayout,
                entries: [
                    {
                        binding: 0,
                        resource: {
                            buffer: isActiveBuffer,
                            size: 4 * Math.min(numElements, this.maxDispatchSize),
                            offset: offset,
                        },
                    },
                    {
                        binding: 1,
                        resource: {
                            buffer: offsetsBuffer,
                            size: 4 * Math.min(numElements, this.maxDispatchSize),
                            offset: offset,
                        },
                    },
                    {
                        binding: 2,
                        resource: {
                            buffer: compactPassOffset,
                            size: 4,
                            offset: i * 256,
                        },
                    },
                    {
                        binding: 3,
                        resource: {
                            buffer: outputBuffer,
                        },
                    },
                ],
            });
        } else {
            streamCompactBG = this.device.createBindGroup({
                layout: this.streamCompactBGLayout,
                entries: [
                    {
                        binding: 0,
                        resource: {
                            buffer: isActiveBuffer,
                            size: 4 * (numElements % this.maxDispatchSize),
                            offset: offset,
                        },
                    },
                    {
                        binding: 1,
                        resource: {
                            buffer: offsetsBuffer,
                            size: 4 * (numElements % this.maxDispatchSize),
                            offset: offset,
                        },
                    },
                    {
                        binding: 2,
                        resource: {
                            buffer: compactPassOffset,
                            size: 4,
                            offset: i * 256,
                        },
                    },
                    {
                        binding: 3,
                        resource: {
                            buffer: outputBuffer,
                        },
                    },
                ],
            });
        }
        pass.setBindGroup(0, streamCompactBG);
        pass.dispatchWorkgroups(Math.ceil(numWorkGroups / 8), 1, 1);
    }
    pass.end();
    this.device.queue.submit([commandEncoder.finish()]);
    await this.device.queue.onSubmittedWorkDone();
};

StreamCompact.prototype.compactActive =
    async function(numElements, isActiveBuffer, offsetsBuffer, dataBuffer, outputBuffer) {
    // No push constants in the API? This is really a hassle to hack together
    // because I also have to obey (at least Dawn's rule is it part of the spec?)
    // that the dynamic offsets be 256b aligned
    // Please add push constants!
    var numChunks = Math.ceil(numElements / this.maxDispatchSize);
    var compactPassOffset = this.device.createBuffer({
        size: numChunks * 256,
        usage: GPUBufferUsage.UNIFORM,
        mappedAtCreation: true,
    });
    {
        var map = new Uint32Array(compactPassOffset.getMappedRange());
        for (var i = 0; i < numChunks; ++i) {
            map[i * 64] = i * this.maxDispatchSize;
        }
        compactPassOffset.unmap();
    }

    var dataBG = this.device.createBindGroup(
        {layout: this.dataBGLayout, entries: [{binding: 0, resource: {buffer: dataBuffer}}]});

    var commandEncoder = this.device.createCommandEncoder();
    var pass = commandEncoder.beginComputePass();
    pass.setPipeline(this.streamCompactDataPipeline);
    for (var i = 0; i < numChunks; ++i) {
        var numWorkGroups =
            Math.min(numElements - i * this.maxDispatchSize, this.maxDispatchSize);

        // Have to create bind groups here because dynamic offsets are not allowed
        var streamCompactBG = this.device.createBindGroup({
            layout: this.streamCompactBGLayout,
            entries: [
                {
                    binding: 0,
                    resource: {
                        buffer: isActiveBuffer,
                    },
                },
                {
                    binding: 1,
                    resource: {
                        buffer: offsetsBuffer,
                    },
                },
                {
                    binding: 2,
                    resource: {
                        buffer: compactPassOffset,
                        size: 4,
                        offset: i * 256,
                    },
                },
                {
                    binding: 3,
                    resource: {
                        buffer: outputBuffer,
                    },
                },
            ],
        });
        pass.setBindGroup(0, streamCompactBG);
        pass.setBindGroup(1, dataBG);
        pass.dispatchWorkgroups(Math.ceil(numWorkGroups / 8), 1, 1);
    }
    pass.end();
    this.device.queue.submit([commandEncoder.finish()]);
    await this.device.queue.onSubmittedWorkDone();
};
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API