io/scidac

Search:
Group by:

SciDAC file format implementation built on LIME

SciDAC files use LIME as the container format with specific record types and XML metadata for lattice field data. This module provides high-level abstractions for reading and writing SciDAC-formatted lattice data.

Standard SciDAC record types:

  • scidac-private-file-xml: File-level metadata
  • scidac-private-record-xml: Record-level metadata
  • scidac-binary-data: Binary field data
  • ildg-format: ILDG-specific format info
  • ildg-binary-data: ILDG gauge configuration data

Reference: QIO library (https://github.com/usqcd-software/qio)

Types

ILDGFormatInfo = object
  version*: string
  field*: string
  precision*: int
  lx*, ly*, lz*, lt*: int
ILDG format metadata
ILDGReader = ref object
  reader*: LimeReader
  formatInfo*: ILDGFormatInfo
  lfn*: string
SciDACChecksum = object
  version*: string
  suma*: uint32
  sumb*: uint32
SciDAC checksum with two 32-bit components
SciDACFileInfo = object
  version*: string
  spacetime*: int
  dims*: seq[int]
  volfmt*: int
Private file-level metadata
SciDACPrecision = enum
  spSingle = "F", spDouble = "D"
SciDACReader = ref object
  reader*: LimeReader
  fileInfo*: SciDACFileInfo
  storedChecksum*: SciDACChecksum
  hasChecksum*: bool
SciDACRecordInfo = object
  version*: string
  date*: string
  recordtype*: int
  datatype*: string
  precision*: SciDACPrecision
  colors*: int
  spins*: int
  typesize*: int
  datacount*: int
Private record-level metadata
SciDACTypeSize = enum
  stReal = 1, stComplex = 2, stColorVector = 6, stColorMatrix = 18,
  stDiracSpinor = 24, stPropagator = 288
Common type sizes for lattice QCD
SciDACUserInfo = object
  info*: string
User-supplied metadata (application-specific)
SciDACWriter = ref object
  writer*: LimeWriter
  fileInfo*: SciDACFileInfo

Consts

ILDGBinaryData = "ildg-binary-data"
ILDGDataLFN = "ildg-data-lfn"
ILDGFormat = "ildg-format"
SciDACBinaryData = "scidac-binary-data"
SciDACChecksumRecord = "scidac-checksum"
SciDACFileXml = "scidac-file-xml"
SciDACPrivateFileXml = "scidac-private-file-xml"
SciDACPrivateRecordXml = "scidac-private-record-xml"
SciDACRecordXml = "scidac-record-xml"

Procs

proc `$`(cs: SciDACChecksum): string {....raises: [], tags: [], forbids: [].}
Format checksum as string
proc calcDataSize(fileInfo: SciDACFileInfo; recordInfo: SciDACRecordInfo): int64 {.
    ...raises: [], tags: [], forbids: [].}
Calculate expected binary data size
proc close(r: ILDGReader) {....raises: [IOError, OSError], tags: [WriteIOEffect],
                            forbids: [].}
proc close(r: SciDACReader) {....raises: [IOError, OSError], tags: [WriteIOEffect],
                              forbids: [].}
proc close(w: SciDACWriter): LimeStatus {....raises: [IOError, OSError],
    tags: [WriteIOEffect], forbids: [].}
proc combineChecksums(cs1, cs2: SciDACChecksum): SciDACChecksum {....raises: [],
    tags: [], forbids: [].}
Combine two checksums (for parallel reduction)
proc crc32(data: openArray[byte]): uint32 {....raises: [], tags: [], forbids: [].}
Compute CRC32 checksum (IEEE 802.3 polynomial)
proc defaultRecordInfo(precision: SciDACPrecision; colors: int = 3;
                       spins: int = 0; typesize: int = 18; datacount: int = 4): SciDACRecordInfo {.
    ...raises: [], tags: [TimeEffect], forbids: [].}
Create default record info for gauge configurations
proc generateChecksumXml(cs: SciDACChecksum): string {....raises: [], tags: [],
    forbids: [].}
Generate scidac-checksum XML record
proc generateFileXml(info: SciDACFileInfo): string {....raises: [], tags: [],
    forbids: [].}
Generate SciDAC private file XML
proc generateILDGFormatXml(info: ILDGFormatInfo): string {....raises: [], tags: [],
    forbids: [].}
Generate ILDG format XML
proc generateRecordXml(info: SciDACRecordInfo): string {....raises: [], tags: [],
    forbids: [].}
Generate SciDAC private record XML
proc generateUserXml(info: SciDACUserInfo): string {....raises: [], tags: [],
    forbids: [].}
Generate user info XML wrapper
proc initSciDACChecksum(): SciDACChecksum {....raises: [], tags: [], forbids: [].}
Initialize an empty checksum
proc newFileInfo(dims: openArray[int]; volfmt: int = 0): SciDACFileInfo {.
    ...raises: [], tags: [], forbids: [].}
Create file info from lattice dimensions
proc newILDGReader(filename: string): ILDGReader {....raises: [IOError], tags: [],
    forbids: [].}
Open an ILDG gauge configuration file
proc newSciDACReader(filename: string): SciDACReader {....raises: [IOError],
    tags: [], forbids: [].}
Open a SciDAC file for reading
proc newSciDACWriter(filename: string; fileInfo: SciDACFileInfo): SciDACWriter {.
    ...raises: [IOError], tags: [], forbids: [].}
Create a new SciDAC file for writing
proc parseChecksumXml(xml: string): SciDACChecksum {.
    ...raises: [IOError, OSError, ValueError, Exception, XmlError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Parse scidac-checksum XML record
proc parseFileXml(xml: string): SciDACFileInfo {.
    ...raises: [IOError, OSError, ValueError, Exception, XmlError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Parse SciDAC private file XML
proc parseILDGFormatXml(xml: string): ILDGFormatInfo {.
    ...raises: [IOError, OSError, ValueError, Exception, XmlError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Parse ILDG format XML
proc parseRecordXml(xml: string): SciDACRecordInfo {.
    ...raises: [IOError, OSError, ValueError, Exception, XmlError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Parse SciDAC private record XML
proc readBinaryData(r: SciDACReader): seq[byte] {.
    ...raises: [IOError, OSError, ValueError, Exception, XmlError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Read the binary data from current position Call this after iterating with messages Also reads the following checksum record if present
proc readBinaryDataTyped[T](r: SciDACReader): seq[T]
Read binary data with type conversion
proc readFileInfo(r: SciDACReader): SciDACFileInfo {.
    ...raises: [IOError, OSError, ValueError, Exception, XmlError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Read the file-level metadata (usually first record)
proc readFormat(r: ILDGReader): ILDGFormatInfo {.
    ...raises: [IOError, OSError, ValueError, Exception, XmlError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Read ILDG format information
proc readGaugeField(r: ILDGReader): seq[byte] {....raises: [IOError, OSError],
    tags: [ReadIOEffect], forbids: [].}
Read the gauge field binary data
proc updateChecksum(cs: var SciDACChecksum; data: openArray[byte];
                    siteIndex: uint32 = 0) {....raises: [], tags: [], forbids: [].}
Update checksum with data from a site using SciDAC/QIO algorithm siteIndex is the global lexicographic site index Algorithm: CRC32 of site data, then rotated by (rank % 29) and (rank % 31)
proc writeField[T](w: SciDACWriter; data: openArray[T];
                   recordInfo: SciDACRecordInfo; userXml: string = ""): LimeStatus
Write a lattice field with metadata
proc writeFieldBytes(w: SciDACWriter; data: openArray[byte];
                     recordInfo: SciDACRecordInfo; userXml: string = ""): LimeStatus {.
    ...raises: [IOError, OSError], tags: [WriteIOEffect], forbids: [].}
Write raw bytes as field data
proc writeFileInfo(w: SciDACWriter; userXml: string = ""): LimeStatus {.
    ...raises: [IOError, OSError], tags: [WriteIOEffect], forbids: [].}
Write the file-level metadata

Iterators

iterator messages(r: SciDACReader): tuple[recordInfo: SciDACRecordInfo,
    userXml: string, checksum: SciDACChecksum] {.
    ...raises: [IOError, OSError, ValueError, Exception, XmlError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Iterate over SciDAC messages, yielding record info, user XML, and checksum After yielding, the reader is positioned at the binary data record