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/crillab/d4v2
27 March 2023, 21:09:18 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
Revision c4239d526043da01142cc81ef1b5aad2d198ff5d authored by JM on 30 September 2022, 13:33:50 UTC, committed by JM on 30 September 2022, 13:33:50 UTC
licence changed
1 parent 1606471
  • Files
  • Changes
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    • c4239d526043da01142cc81ef1b5aad2d198ff5d
    No releases to show
  • 6c3f6d1
  • /
  • 3rdParty
  • /
  • patoh
  • /
  • try.c
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:c4239d526043da01142cc81ef1b5aad2d198ff5d
origin badgedirectory badge
swh:1:dir:fd3667aca147f80b28facce259251b5a6bda27cc
origin badgecontent badge
swh:1:cnt:cc918dd3f809ceb6c3b048c530eda48a27c0154b
origin badgesnapshot badge
swh:1:snp:0020192acd512b1a686e83d94dc283eedf58e892

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: c4239d526043da01142cc81ef1b5aad2d198ff5d authored by JM on 30 September 2022, 13:33:50 UTC
licence changed
Tip revision: c4239d5
try.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include "patoh.h"


#define NCONST        2
#define WDIFF         10


#define umax(a, b)	(((a) >= (b)) ? (a) : (b))

#define usRandom(s)     srand(s)
#define uRandom(l)      (rand() % l)



void usage(char *name)
{
 printf("usage: %s <partitioner-char> <hypergraph-filename> <#parts>\n", name);
 printf("\t<partitioner-char> can be:\n");
 printf("\t\tP: regular partition\n");
 printf("\t\tF: with first #parts cells are fixed to a different part\n");
 printf("\t\tM: %d-constraint partition\n", NCONST);
 printf("\t\tA: run all of them\n");
 printf("\t\tT: run all of them with skewed target weights\n");
 exit(1);
}


void PrintInfo(char *pname, int _k, int *partweights, int cut, int _nconst, float *targetweights)
{
    double             *tot, *maxi;
    int                i, j;


    tot = (double *) malloc(sizeof(double)*_nconst);
    maxi = (double *) malloc(sizeof(double)*_nconst);
    
    /* normalize target weight sum to 1.0 */
    for (j=0; j<_nconst; ++j)
        tot[j] = 0.0;
    for (i=0; i<_k; ++i)
        for (j=0; j<_nconst; ++j)
            tot[j] += targetweights[i*_nconst+j];
    for (i=0; i<_k; ++i)
        for (j=0; j<_nconst; ++j)
            targetweights[i*_nconst+j] /= tot[j];
    
    printf("\n-------------------------------------------------------------------");
    printf("\n Partitioner: %s", pname);
    
    printf("\n %d-way cutsize = %d \n", _k, cut);
    
    printf("\nPart Weights are:\n");
    for (i=0; i<_nconst; ++i)
        maxi[i] = tot[i] = 0.0;     
    for (i=0; i<_k; ++i)
        for (j=0; j<_nconst; ++j)
            tot[j] += partweights[i*_nconst+j];
    for (i=0; i<_nconst; ++i) 
        maxi[i] = 0.0;     

    for (i=0; i<_k; ++i) {
        printf("\n %3d :", i);
        for (j=0; j<_nconst; ++j) {
            double im= (double)((double)partweights[i*_nconst+j] - tot[j]*targetweights[i*_nconst+j]) / (tot[j]*targetweights[i*_nconst+j]);
         
            maxi[j] = umax(maxi[j], im);
            printf("%10d (TrgtR:%.3f  imbal:%6.3lf%%) ", partweights[i*_nconst+j], targetweights[i*_nconst+j], 100.0*im);
        }     
    }

    printf("\n MaxImbals are:");
    printf("\n      ");
    for (i=0; i<_nconst; ++i)
        printf("%10.1lf%% ", 100.0*maxi[i]);
    printf("\n"); 
    free(maxi);
    free(tot);
}


int main(int argc, char *argv[])
{
 PaToH_Parameters args;
 int             _c, _n, _nconst, *cwghts, *nwghts, 
     *xpins, *pins, *partvec, cut, *partweights,
     i, j, *cw;
 char           PT;
 float  *targetweights, *skewedtweights;


 if (argc!=4)
     usage(argv[0]);     

 PT = toupper(*argv[1]);
 if (PT!='P' && PT!='F' && PT!='M' && PT!='A' && PT!='T')
     usage(argv[0]);
 usRandom(time(NULL));
 
 
 PaToH_Read_Hypergraph(argv[2], &_c, &_n, &_nconst, &cwghts, 
                       &nwghts, &xpins, &pins);

 printf("===============================================================================\n");
 
 printf("Hypergraph %10s -- #Cells=%6d  #Nets=%6d  #Pins=%8d #Const=%2d\n",
        argv[2], _c, _n, xpins[_n], _nconst);
 
 PaToH_Initialize_Parameters(&args, PATOH_CONPART, 
                             PATOH_SUGPARAM_DEFAULT);

 args._k = atoi(argv[3]);
 args._k = (args._k>2) ? args._k : 2;
 args.seed = 1;
 
 partvec =  (int *) malloc(_c*sizeof(int));
 partweights  = (int *) malloc(NCONST*args._k*sizeof(int));
 targetweights = (float *) malloc(args._k*NCONST*sizeof(float));
 skewedtweights = (float *) malloc(args._k*NCONST*sizeof(float));

 for (i=0; i<args._k; ++i) {
     targetweights[i] = 1.0/(float)args._k;
     skewedtweights[i] = args._k-i;
 }
 
 PaToH_Alloc(&args, _c, _n, NCONST, cwghts, nwghts, 
             xpins, pins);

 

 if (PT=='P' || PT=='A') {     
     PaToH_Partition(&args, _c, _n, cwghts, nwghts, 
                     xpins, pins, partvec, partweights, &cut);
     PrintInfo("Single Constraint", args._k, partweights, cut, 1, targetweights);
     }
 if (PT=='T') {     
     PaToH_Part(&args, _c, _n, 1, 0, cwghts, nwghts, 
                xpins, pins, skewedtweights, partvec, partweights, &cut);

     printf("Skewed tweights:");
     for (i=0; i<args._k; ++i)
         printf("%.3f ", skewedtweights[i]);
     printf("\n");
     PrintInfo("Single Constraint Skewed", args._k, partweights, cut, 1, skewedtweights);
     }
     
 

 if (PT=='F' || PT=='A') {
     memset(partvec, 0xff, _c*sizeof(int));
     for (i=0; i<args._k; ++i)
         partvec[i] = i;
     PaToH_Partition_with_FixCells(&args, _c, _n, cwghts, nwghts, 
                                   xpins, pins, partvec, partweights, &cut);
     PrintInfo("With FixCells", args._k, partweights, cut, 1, targetweights);
     }
 if (PT=='T') {     
     memset(partvec, 0xff, _c*sizeof(int));
     for (i=0; i<args._k; ++i)
         partvec[i] = i;
     PaToH_Part(&args, _c, _n, 1, 1, cwghts, nwghts, 
                xpins, pins, skewedtweights, partvec, partweights, &cut);
     PrintInfo("With FixCells Skewed", args._k, partweights, cut, 1, skewedtweights);
     }


 if (PT=='M' || PT=='A' || PT=='T') {
     _nconst = NCONST;
     
     cw =  (int *) malloc(_c*_nconst*sizeof(int));
     for (i=0; i<_c; ++i) {
         for (j=0; j<_nconst; ++j) {
             int w=cwghts[i]+(uRandom(WDIFF)-WDIFF/2)*j;
             cw[i*_nconst+j] = umax(w, 1);
             }
     }

      for (i=0; i<args._k; ++i)
          for (j=0; j<_nconst;++j) {
              targetweights[i*_nconst+j] = 1.0/(float)args._k;
              skewedtweights[i*_nconst+j] = args._k-i;
          }


     if (PT=='T') {
         PaToH_Part(&args, _c, _n, _nconst, 0, cw, nwghts, 
                    xpins, pins, skewedtweights, partvec, partweights, &cut);
         PrintInfo("MultiConstraint Skewed", args._k, partweights, cut, _nconst, skewedtweights);
     } else {
         PaToH_MultiConst_Partition(&args, _c, _n, _nconst, cw, xpins, pins, partvec, partweights, &cut);
         PrintInfo("MultiConstraint", args._k, partweights, cut, _nconst, targetweights);
     }
     free(cw);
     }

 
 
 free(targetweights);
 free(partweights);
 free(partvec);
 free(cwghts);
 free(nwghts);
 free(xpins);
 free(pins);
  
PaToH_Free();
printf("\n");
 
return 0;
}

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