IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 10, 2009, 4:53:42 PM (17 years ago)
Author:
Paul Price
Message:

Changing API for psRandomAlloc() to make it easier to be deterministic. psRandomAlloc() now takes only a single argument, which is the generator type (only PS_RANDOM_TAUS is currently supported; others could easily be added). The seed used by the generator is set by psRandomSeed(). This allows us to use the same seed for the random number generator over multiple calls, which means that we can be deterministic by setting the seed. The old API for psRandomAlloc() is available using psRandomAllocSpecific(). Added to the configuration setup in psModules to include recording the random seed, and setting if desired. Updated all our products to use this API. Some fixes and updates to the configuration run-time information dumping. ppImage now dumps the configuration at the end, allowing the list of files in the run-time information to be set.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfigRun.c

    r23244 r23259  
    7272
    7373
    74 bool pmConfigRunCommand(pmConfig *config, int argc, const char **argv)
     74bool pmConfigRunCommand(pmConfig *config, int argc, char **argv)
    7575{
    7676    PS_ASSERT_PTR_NON_NULL(config, false);
     
    8181    psString command = NULL;
    8282    for (int i = 0; i < argc; i++) {
    83         psStringAppend(&command, "%s", argv[i]);
     83        psStringAppend(&command, "%s ", argv[i]);
    8484    }
    8585
     
    8989    return true;
    9090}
     91
     92
     93bool pmConfigRunSeed(pmConfig *config, psU64 seed)
     94{
     95    PS_ASSERT_PTR_NON_NULL(config, false);
     96
     97    psMetadata *run = configRun(config);// Run-time information
     98    psAssert(run, "Require run-time information");
     99
     100    if (!seed) {
     101        bool mdok;                          // Status of MD lookup
     102        seed = psMetadataLookupU64(&mdok, run, "SEED");
     103    }
     104    if (!seed) {
     105        bool mdok;                          // Status of MD lookup
     106        seed = psMetadataLookupU64(&mdok, config->user, "SEED");
     107    }
     108
     109    // seed may still be zero by this point
     110    seed = psRandomSeed(seed);
     111    return psMetadataAddU64(run, PS_LIST_TAIL, "SEED", PS_META_REPLACE, "Random number generator seed", seed);
     112}
     113
Note: See TracChangeset for help on using the changeset viewer.