- Timestamp:
- 05/05/14 09:50:53 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/zofits.h
r17766 r17779 8 8 * Author: lyard 9 9 */ 10 11 10 #include "ofits.h" 12 11 #include "huffman.h" … … 16 15 #ifdef HAVE_BOOST_THREAD 17 16 #include <boost/thread.hpp> 17 #else 18 #include <unistd.h> 18 19 #endif 19 20 … … 89 90 public: 90 91 /// static setter for the default number of threads to use. -1 means all available physical cores 91 static uint32_t DefaultNumThreads(const uint32_t &_n=-2) { static uint32_t n=0; if (int32_t(_n)> =-1) n=_n; return n; }92 static uint32_t DefaultNumThreads(const uint32_t &_n=-2) { static uint32_t n=0; if (int32_t(_n)>-2) n=_n; return n; } 92 93 static uint32_t DefaultMaxMemory(const uint32_t &_n=0) { static uint32_t n=1000000; if (_n>0) n=_n; return n; } 93 94 static uint32_t DefaultMaxNumTiles(const uint32_t &_n=0) { static uint32_t n=1000; if (_n>0) n=_n; return n; } … … 119 120 fWriteToDiskQueue(std::bind(&zofits::WriteBufferToDisk, this, std::placeholders::_1), false) 120 121 { 121 open(fname);122 122 InitMemberVariables(numTiles, rowPerTile, size_t(maxUsableMem)*1000); 123 123 SetNumThreads(DefaultNumThreads()); 124 open(fname); 124 125 } 125 126 … … 131 132 fWriteToDiskQueue(std::bind(&zofits::WriteBufferToDisk, this, std::placeholders::_1), false) 132 133 { 133 open(fname);134 134 InitMemberVariables(numTiles, rowPerTile, size_t(maxUsableMem)*1000); 135 135 SetNumThreads(DefaultNumThreads()); 136 open(fname); 136 137 } 137 138 … … 576 577 return false; 577 578 578 const size_t size = SizeFromType(typechar);579 const size_t size = FITS::SizeFromType(typechar); 579 580 580 581 Table::Column col; … … 589 590 fRealColumns.emplace_back(col, comp); 590 591 591 SetStr("ZFORM"+std::to_string((long long int)(fRealColumns.size())), std::to_string((long long int)(cnt))+typechar, "format of "+name+" "+ CommentFromType(typechar));592 SetStr("ZFORM"+std::to_string((long long int)(fRealColumns.size())), std::to_string((long long int)(cnt))+typechar, "format of "+name+" "+FITS::CommentFromType(typechar)); 592 593 SetStr("ZCTYP"+std::to_string((long long int)(fRealColumns.size())), "FACT", "Compression type: FACT"); 593 594 … … 614 615 #else 615 616 unsigned int num_available_cores = std::thread::hardware_concurrency(); 617 if (num_available_cores == 0) 618 num_available_cores = sysconf(_SC_NPROCESSORS_ONLN); 616 619 #endif 617 620 // could not detect number of available cores from system properties... … … 637 640 void reallocateBuffers() 638 641 { 639 const size_t chunk_size = fRealRowWidth*fNumRowsPerTile + fRealColumns.size()*sizeof(FITS::BlockHeader) + sizeof(FITS::TileHeader) + 8; //+8 for checksuming; 642 size_t total_block_head_size = 0; 643 for (auto it=fRealColumns.begin(); it!=fRealColumns.end(); it++) 644 total_block_head_size += it->block_head.getSizeOnDisk(); 645 646 const size_t chunk_size = fRealRowWidth*fNumRowsPerTile + total_block_head_size + sizeof(FITS::TileHeader) + 8; //+8 for checksuming; 640 647 fMemPool.setChunkSize(chunk_size); 641 642 648 fSmartBuffer = fMemPool.malloc(); 643 649 fRawSumBuffer.resize(fRealRowWidth + 4-fRealRowWidth%4); //for checksuming
Note:
See TracChangeset
for help on using the changeset viewer.