Changeset 14e73bb for GenericIO.cxx


Ignore:
Timestamp:
04/12/16 19:22:09 (9 years ago)
Author:
Hal Finkel <hfinkel@…>
Branches:
master, pympi
Children:
754e14c
Parents:
8f0a211
git-author:
Hal Finkel <hfinkel@…> (04/12/16 19:22:09)
git-committer:
Hal Finkel <hfinkel@…> (04/12/16 19:22:09)
Message:

Misc. improvements to splitting and error handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GenericIO.cxx

    r8f0a211 r14e73bb  
    5151#include <fstream> 
    5252#include <stdexcept> 
     53#include <iterator> 
    5354#include <algorithm> 
    5455#include <cassert> 
     
    6667 
    6768#ifdef __bgq__ 
    68 #include <spi/include/kernel/location.h> 
    69 #include <spi/include/kernel/process.h> 
    70 #include <firmware/include/personality.h> 
     69#include <mpix.h> 
    7170#endif 
    7271 
     
    206205        continue; 
    207206 
    208       throw runtime_error("Unable to read " + D + " from file: " + FileName); 
     207      throw runtime_error("Unable to read " + D + " from file: " + FileName + 
     208                          ": " + strerror(errno)); 
    209209    } 
    210210 
     
    224224        continue; 
    225225 
    226       throw runtime_error("Unable to write " + D + " to file: " + FileName); 
     226      throw runtime_error("Unable to write " + D + " to file: " + FileName + 
     227                          ": " + strerror(errno)); 
    227228    } 
    228229 
     
    11511152 
    11521153  return (int) RH->GlobalRank; 
     1154} 
     1155 
     1156void GenericIO::getSourceRanks(vector<int> &SR) { 
     1157  SR.clear(); 
     1158 
     1159  if (Redistributing) { 
     1160    std::copy(SourceRanks.begin(), SourceRanks.end(), std::back_inserter(SR)); 
     1161    return; 
     1162  } 
     1163 
     1164  int Rank; 
     1165#ifndef GENERICIO_NO_MPI 
     1166  MPI_Comm_rank(Comm, &Rank); 
     1167#else 
     1168  Rank = 0; 
     1169#endif 
     1170 
     1171  SR.push_back(Rank); 
    11531172} 
    11541173 
     
    15051524        dofs.write((const char *) Data, ReadSize); 
    15061525        dofs.close(); 
     1526 
     1527        uint64_t RawCRC = crc64_omp(Data, ReadSize - CRCSize); 
     1528        unsigned char *UData = (unsigned char *) Data; 
     1529        crc64_invert(RawCRC, &UData[ReadSize - CRCSize]); 
     1530        uint64_t NewCRC = crc64_omp(Data, ReadSize); 
     1531        std::cerr << "Recalulated CRC: " << NewCRC << ((NewCRC == -1) ? "ok" : "bad") << "\n"; 
    15071532        break; 
    15081533      } 
     
    16151640void GenericIO::setNaturalDefaultPartition() { 
    16161641#ifdef __bgq__ 
    1617   Personality_t pers; 
    1618   Kernel_GetPersonality(&pers, sizeof(pers)); 
    1619  
    1620   // Nodes in an ION Partition 
    1621   int SPLIT_A = 2; 
    1622   int SPLIT_B = 2; 
    1623   int SPLIT_C = 4; 
    1624   int SPLIT_D = 4; 
    1625   int SPLIT_E = 2; 
    1626  
    1627   int Anodes, Bnodes, Cnodes, Dnodes, Enodes; 
    1628   int Acoord, Bcoord, Ccoord, Dcoord, Ecoord; 
    1629   int A_color, B_color, C_color, D_color, E_color; 
    1630   int A_blocks, B_blocks, C_blocks, D_blocks, E_blocks; 
    1631   uint32_t id_on_node; 
    1632   int ranks_per_node, color; 
    1633  
    1634   Anodes = pers.Network_Config.Anodes; 
    1635   Acoord = pers.Network_Config.Acoord; 
    1636  
    1637   Bnodes = pers.Network_Config.Bnodes; 
    1638   Bcoord = pers.Network_Config.Bcoord; 
    1639  
    1640   Cnodes = pers.Network_Config.Cnodes; 
    1641   Ccoord = pers.Network_Config.Ccoord; 
    1642  
    1643   Dnodes = pers.Network_Config.Dnodes; 
    1644   Dcoord = pers.Network_Config.Dcoord; 
    1645  
    1646   Enodes = pers.Network_Config.Enodes; 
    1647   Ecoord = pers.Network_Config.Ecoord; 
    1648  
    1649   A_color  = Acoord /  SPLIT_A; 
    1650   B_color  = Bcoord /  SPLIT_B; 
    1651   C_color  = Ccoord /  SPLIT_C; 
    1652   D_color  = Dcoord /  SPLIT_D; 
    1653   E_color  = Ecoord /  SPLIT_E; 
    1654  
    1655   // Number of blocks 
    1656   A_blocks = Anodes / SPLIT_A; 
    1657   B_blocks = Bnodes / SPLIT_B; 
    1658   C_blocks = Cnodes / SPLIT_C; 
    1659   D_blocks = Dnodes / SPLIT_D; 
    1660   E_blocks = Enodes / SPLIT_E; 
    1661  
    1662   color = (A_color * (B_blocks * C_blocks * D_blocks * E_blocks)) 
    1663     + (B_color * (C_blocks * D_blocks * E_blocks)) 
    1664     + (C_color * ( D_blocks * E_blocks)) 
    1665     + (D_color * ( E_blocks)) 
    1666     + E_color; 
    1667  
    1668   DefaultPartition = color; 
     1642  DefaultPartition = MPIX_IO_link_id(); 
    16691643#else 
    16701644#ifndef GENERICIO_NO_MPI 
Note: See TracChangeset for help on using the changeset viewer.