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

Raw File Download

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.

  • content
content badge
swh:1:cnt:3a4d3e5f77fa50d7983cd55105a8aa944573f4c8

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.

  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
// Generate the work group ID offset buffer and the dynamic offset buffer to use for chunking
// up a large compute dispatch. The start of the push constants data will be:
// {
//      u32: global work group id offset
//      u32: totalWorkGroups
//      ...: up to 248 bytes additional data (if any) from the pushConstants parameter,
//           passed as an ArrayBuffer or TypedArray
// }
// ID offset (u32),
export function buildPushConstantsBuffer(device, totalWorkGroups, pushConstants)
{
    var dynamicOffsets = [];
    var dispatchSizes = [];

    var numDynamicOffsets =
        Math.ceil(totalWorkGroups / device.limits.maxComputeWorkgroupsPerDimension);
    var idOffsetsBuffer = device.createBuffer({
        size: 256 * numDynamicOffsets,
        usage: GPUBufferUsage.UNIFORM,
        mappedAtCreation: true,
    });
    {
        var pushConstantsView = null;
        if (pushConstants) {
            var pc = pushConstants;
            if (pushConstants.buffer) {
                pc = pushConstants.buffer;
            }
            if (pc.byteLength > 248) {
                console.log(`Error: push constants can be at most 248 bytes`);
            }
            pushConstantsView = new Uint8Array(pc);
        }
        var mapping = idOffsetsBuffer.getMappedRange();
        for (var i = 0; i < numDynamicOffsets; ++i) {
            dynamicOffsets.push(i * 256);

            if (i + 1 < numDynamicOffsets) {
                dispatchSizes.push(device.limits.maxComputeWorkgroupsPerDimension);
            } else {
                dispatchSizes.push(totalWorkGroups %
                                   device.limits.maxComputeWorkgroupsPerDimension);
            }

            // Write the push constants data
            var u32view = new Uint32Array(mapping, i * 256, 2);
            u32view[0] = device.limits.maxComputeWorkgroupsPerDimension * i;
            u32view[1] = totalWorkGroups;

            // Copy in any additional push constants data if provided
            if (pushConstantsView) {
                var u8view = new Uint8Array(mapping, i * 256 + 8, 248);
                u8view.set(pushConstantsView);
            }
        }
        idOffsetsBuffer.unmap();
    }
    dynamicOffsets = new Uint32Array(dynamicOffsets);

    return {
        nOffsets: numDynamicOffsets,
        gpuBuffer: idOffsetsBuffer,
        dynamicOffsets: dynamicOffsets,
        dispatchSizes: dispatchSizes,
    };
}

back to top

Software Heritage — Copyright (C) 2015–2026, 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