Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • N NIFTy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 20
    • Issues 20
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

On Monday, 27th March 9 a.m., the user backend of GitLab will get a reconfiguration. A new login to the web interface may be necessary.

  • ift
  • NIFTy
  • Merge requests
  • !836

remove note mpi tasks in sample_list

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Jakob Roth requested to merge sample_list_mpi_load into NIFTy_8 Jan 17, 2023
  • Overview 15
  • Commits 2
  • Pipelines 2
  • Changes 1

In the Sample List documentation, we have a note that a sample list has to be loaded with the sample number of MPI tasks with which the Sample List was saved. Actually, this condition is not necessary. The number of MPI tasks does neither affect the order in which the samples are stored nor the order in which the samples are loaded again. To convince yourself, here are two code snippets:

Save a sample list:

import nifty8 as ift

from mpi4py import MPI
comm = MPI.COMM_WORLD
n_tasks = comm.Get_size()
my_rank = comm.Get_rank()
master = my_rank == 0

n_samples = 5

sp = ift.RGSpace(1)
mean = ift.full(sp, 0)

# create samples with "value of sample=index in list"
# create samples mpi parallel according to nifty convention
loc_inds = ift.utilities.shareRange(n_samples, n_tasks, my_rank)
smps = [ift.full(sp, ii) for ii in range(*loc_inds)]
neg = [False for _ in range(*loc_inds)]
samples = ift.ResidualSampleList(mean, smps, neg, comm)


samples.save('smp')
if master:
    print(f'saved sample list with {n_samples} samples distributed on {n_tasks} tasks')

Read the sample list and verify the number of samples and their order:

import nifty8 as ift

from mpi4py import MPI
comm = MPI.COMM_WORLD
n_tasks = comm.Get_size()
my_rank = comm.Get_rank()
master = my_rank == 0

samples = ift.ResidualSampleList.load('smp', comm)
n_samples = samples.n_samples

# check order of samples
for ii, smp in enumerate(samples.iterator()):
    assert(ii == smp.val[0])

if master:
    print(f'read sample list with {n_samples} samples, and distribute on {n_tasks} tasks')
    print('verified order of samples')

Thanks for noticing this Maximilian!

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: sample_list_mpi_load