Commit 6f86d21e authored by Mark Kim's avatar Mark Kim

clang is my nemesis.

parent ce00cc6e
......@@ -50,8 +50,8 @@ struct BlockReader
, m_maxbits(maxbits)
, MaxIndex(words.GetNumberOfValues() - 1)
{
Index = (block_idx * maxbits) / (sizeof(Word) * 8);
m_buffer = Words.Get(Index);
Index = static_cast<size_t>(block_idx * maxbits) / (sizeof(Word) * 8);
m_buffer = static_cast<Word>(Words.Get(Index));
m_current_bit = (block_idx * maxbits) % vtkm::Int32((sizeof(Word) * 8));
m_buffer >>= m_current_bit;
......@@ -73,7 +73,7 @@ struct BlockReader
++Index;
if (Index > MaxIndex)
return false;
m_buffer = Words.Get(Index);
m_buffer = static_cast<Word>(Words.Get(Index));
}
return bit;
}
......@@ -99,7 +99,7 @@ struct BlockReader
// just read in 0s if someone asks for more bits past the end of the array.
// not sure what the best way to deal with this i
Index = vtkm::Min(MaxIndex, Index + 1);
m_buffer = Words.Get(Index);
m_buffer = static_cast<Word>(Words.Get(Index));
next_read = n_bits - first_read;
}
......
......@@ -52,10 +52,10 @@ struct BlockWriter
, m_maxbits(maxbits)
, Portal(portal)
{
m_word_index = (block_idx * maxbits) / (sizeof(Word) * 8);
m_word_index = (block_idx * maxbits) / vtkm::Int32(sizeof(Word) * 8);
// debug_index = m_word_index;
//std::cout<<"** Block "<<block_idx<<" start "<<m_word_index<<"\n";
m_start_bit = vtkm::Int32((block_idx * maxbits) % (sizeof(Word) * 8));
m_start_bit = vtkm::Int32((block_idx * maxbits) % vtkm::Int32(sizeof(Word) * 8));
}
template <typename T>
......@@ -109,12 +109,13 @@ struct BlockWriter
{
//std::cout<<"write nbits "<<n_bits<<" "<<m_current_bit<<"\n";
//bool print = m_word_index == 0 && m_start_bit == 0;
const unsigned int wbits = sizeof(Word) * 8;
const int wbits = sizeof(Word) * 8;
//if(bits == 0) { printf("no\n"); return;}
//uint seg_start = (m_start_bit + bit_offset) % wbits;
//int write_index = m_word_index + (m_start_bit + bit_offset) / wbits;
unsigned int seg_start = (m_start_bit + m_current_bit) % wbits;
vtkm::Id write_index = m_word_index + vtkm::Id((m_start_bit + m_current_bit) / wbits);
vtkm::Id write_index = m_word_index;
write_index += vtkm::Id((m_start_bit + m_current_bit) / wbits);
unsigned int seg_end = seg_start + n_bits - 1;
//int write_index = m_word_index;
unsigned int shift = seg_start;
......@@ -157,12 +158,13 @@ struct BlockWriter
vtkm::UInt32 VTKM_EXEC write_bit(const unsigned int& bit)
{
//bool print = m_word_index == 0 && m_start_bit == 0;
const unsigned int wbits = sizeof(Word) * 8;
const int wbits = sizeof(Word) * 8;
//if(bits == 0) { printf("no\n"); return;}
//uint seg_start = (m_start_bit + bit_offset) % wbits;
//int write_index = m_word_index + (m_start_bit + bit_offset) / wbits;
unsigned int seg_start = (m_start_bit + m_current_bit) % wbits;
vtkm::Id write_index = m_word_index + vtkm::Id((m_start_bit + m_current_bit) / wbits);
vtkm::Id write_index = m_word_index;
write_index += vtkm::Id((m_start_bit + m_current_bit) / wbits);
//uint seg_end = seg_start;
//int write_index = m_word_index;
unsigned int shift = seg_start;
......
......@@ -165,13 +165,13 @@ struct inv_transform<4>
VTKM_EXEC
vtkm::Int64 uint2int(vtkm::UInt64 x)
{
return (x ^ 0xaaaaaaaaaaaaaaaaull) - 0xaaaaaaaaaaaaaaaaull;
return static_cast<vtkm::Int64>((x ^ 0xaaaaaaaaaaaaaaaaull) - 0xaaaaaaaaaaaaaaaaull);
}
VTKM_EXEC
vtkm::Int32 uint2int(vtkm::UInt32 x)
{
return (x ^ 0xaaaaaaaau) - 0xaaaaaaaau;
return static_cast<vtkm::Int32>((x ^ 0xaaaaaaaau) - 0xaaaaaaaau);
}
// Note: I die a little inside everytime I write this sort of template
......@@ -197,7 +197,7 @@ VTKM_EXEC void decode_ints(ReaderType<BlockSize, PortalType>& reader,
// read bit plane
vtkm::UInt32 m = vtkm::Min(n, vtkm::UInt32(bits));
bits -= m;
x = reader.read_bits(m);
x = reader.read_bits(static_cast<vtkm::Int32>(m));
for (; n < BlockSize && bits && (bits--, reader.read_bit()); x += (Word)1 << n++)
for (; n < (BlockSize - 1) && bits && (bits--, !reader.read_bit()); n++)
;
......@@ -220,7 +220,7 @@ VTKM_EXEC void zfp_decode(Scalar* fblock,
vtkm::UInt32 blockIdx,
PortalType stream)
{
zfp::BlockReader<BlockSize, PortalType> reader(stream, maxbits, blockIdx);
zfp::BlockReader<BlockSize, PortalType> reader(stream, maxbits, vtkm::Int32(blockIdx));
using Int = typename zfp::zfp_traits<Scalar>::Int;
using UInt = typename zfp::zfp_traits<Scalar>::UInt;
......@@ -233,7 +233,7 @@ VTKM_EXEC void zfp_decode(Scalar* fblock,
if (cont)
{
vtkm::UInt32 ebits = zfp::get_ebits<Scalar>() + 1;
vtkm::UInt32 ebits = static_cast<vtkm::UInt32>(zfp::get_ebits<Scalar>()) + 1;
vtkm::UInt32 emax;
if (!zfp::is_int<Scalar>())
......@@ -245,7 +245,8 @@ VTKM_EXEC void zfp_decode(Scalar* fblock,
//std::cout<<"b "<<b<<"\n";
//std::cout<<"ebias "<<zfp::get_ebias<Scalar>()<<"\n";
//emax = vtkm::UInt32(b - zfp::get_ebias<Scalar>());
emax = vtkm::UInt32(reader.read_bits(ebits - 1) - zfp::get_ebias<Scalar>());
emax = vtkm::UInt32(reader.read_bits(static_cast<vtkm::Int32>(ebits) - 1));
emax -= static_cast<vtkm::UInt32>(zfp::get_ebias<Scalar>());
//std::cout<<"EMAX "<<emax<<"\n";
}
else
......@@ -279,7 +280,7 @@ VTKM_EXEC void zfp_decode(Scalar* fblock,
// std::cout<<"tid "<<i<<" "<<iblock[i]<<"\n";
//}
Scalar inv_w = dequantize<Int, Scalar>(1, emax);
Scalar inv_w = dequantize<Int, Scalar>(1, static_cast<vtkm::Int32>(emax));
//std::cout<<"dequantize factor "<<inv_w<<"\n";
......
......@@ -92,7 +92,8 @@ public:
}
zfp::zfp_decode<BlockSize>(fblock, MaxBits, static_cast<vtkm::UInt32>(blockIdx), stream);
zfp::zfp_decode<BlockSize>(
fblock, vtkm::Int32(MaxBits), static_cast<vtkm::UInt32>(blockIdx), stream);
vtkm::Id zfpBlock;
......
......@@ -104,7 +104,8 @@ public:
}
zfp::zfp_decode<BlockSize>(fblock, MaxBits, static_cast<vtkm::UInt32>(blockIdx), stream);
zfp::zfp_decode<BlockSize>(
fblock, vtkm::Int32(MaxBits), static_cast<vtkm::UInt32>(blockIdx), stream);
vtkm::Id2 zfpBlock;
zfpBlock[0] = blockIdx % ZFPDims[0];
......
......@@ -112,7 +112,8 @@ public:
}
zfp::zfp_decode<BlockSize>(fblock, MaxBits, static_cast<vtkm::UInt32>(blockIdx), stream);
zfp::zfp_decode<BlockSize>(
fblock, vtkm::Int32(MaxBits), static_cast<vtkm::UInt32>(blockIdx), stream);
//for(int i = 0; i < BlockSize; ++i)
......
......@@ -149,13 +149,14 @@ inline VTKM_EXEC UInt int2uint(const Int x);
template <>
inline VTKM_EXEC vtkm::UInt64 int2uint<vtkm::Int64, vtkm::UInt64>(const vtkm::Int64 x)
{
return (x + (vtkm::UInt64)0xaaaaaaaaaaaaaaaaull) ^ (vtkm::UInt64)0xaaaaaaaaaaaaaaaaull;
return (static_cast<vtkm::UInt64>(x) + (vtkm::UInt64)0xaaaaaaaaaaaaaaaaull) ^
(vtkm::UInt64)0xaaaaaaaaaaaaaaaaull;
}
template <>
inline VTKM_EXEC vtkm::UInt32 int2uint<vtkm::Int32, vtkm::UInt32>(const vtkm::Int32 x)
{
return (x + (vtkm::UInt32)0xaaaaaaaau) ^ (vtkm::UInt32)0xaaaaaaaau;
return (static_cast<vtkm::UInt32>(x) + (vtkm::UInt32)0xaaaaaaaau) ^ (vtkm::UInt32)0xaaaaaaaau;
}
......@@ -268,7 +269,7 @@ VTKM_EXEC void encode_block(BlockWriter<BlockSize, PortalType>& stream,
vtkm::UInt32 intprec = CHAR_BIT * (vtkm::UInt32)sizeof(UInt);
vtkm::UInt32 kmin =
intprec > (vtkm::UInt32)maxprec ? intprec - static_cast<vtkm::UInt32>(maxprec) : 0;
vtkm::UInt32 bits = static_cast<vtkm::Int32>(maxbits);
vtkm::UInt32 bits = static_cast<vtkm::UInt32>(maxbits);
vtkm::UInt32 i, m;
vtkm::UInt32 n = 0;
vtkm::UInt64 x;
......@@ -319,18 +320,18 @@ inline VTKM_EXEC void zfp_encodef(Scalar* fblock,
// std::cout<<"EMAX "<<emax<<"\n";
vtkm::Int32 maxprec =
zfp::precision(emax, zfp::get_precision<Scalar>(), zfp::get_min_exp<Scalar>());
vtkm::UInt32 e = maxprec ? emax + zfp::get_ebias<Scalar>() : 0;
vtkm::UInt32 e = vtkm::UInt32(maxprec ? emax + zfp::get_ebias<Scalar>() : 0);
/* encode block only if biased exponent is nonzero */
if (e)
{
const vtkm::UInt32 ebits = zfp::get_ebits<Scalar>() + 1;
const vtkm::UInt32 ebits = vtkm::UInt32(zfp::get_ebits<Scalar>()) + 1;
blockWriter.write_bits(2 * e + 1, ebits);
Int iblock[BlockSize];
zfp::fwd_cast<Int, Scalar, BlockSize>(iblock, fblock, emax);
encode_block<BlockSize>(blockWriter, maxbits - ebits, maxprec, iblock);
encode_block<BlockSize>(blockWriter, maxbits - vtkm::Int32(ebits), maxprec, iblock);
}
}
......
......@@ -49,7 +49,7 @@ VTKM_EXEC inline void GatherPartial1(Scalar* q,
vtkm::Id x;
for (x = 0; x < nx; x++, offset += sx)
q[x] = scalars.Get(offset);
PadBlock(q, nx, 1);
PadBlock(q, vtkm::UInt32(nx), 1);
}
template <typename Scalar, typename PortalType>
......@@ -146,7 +146,7 @@ public:
//zfp_encode_block<Scalar, ZFP_2D_BLOCK_SIZE>(fblock, maxbits, block_idx, stream);
zfp::ZFPBlockEncoder<BlockSize, Scalar, BitstreamPortal> encoder;
encoder.encode(fblock, MaxBits, vtkm::UInt32(blockIdx), stream);
encoder.encode(fblock, static_cast<vtkm::Int32>(MaxBits), vtkm::UInt32(blockIdx), stream);
}
};
}
......
......@@ -53,10 +53,10 @@ VTKM_EXEC inline void GatherPartial2(Scalar* q,
{
for (x = 0; x < nx; x++, offset += 1)
q[4 * y + x] = scalars.Get(offset);
PadBlock(q + 4 * y, nx, 1);
PadBlock(q + 4 * y, vtkm::UInt32(nx), 1);
}
for (x = 0; x < 4; x++)
PadBlock(q + x, ny, 4);
PadBlock(q + x, vtkm::UInt32(ny), 4);
}
template <typename Scalar, typename PortalType>
......@@ -164,7 +164,7 @@ public:
//zfp_encode_block<Scalar, ZFP_2D_BLOCK_SIZE>(fblock, maxbits, block_idx, stream);
zfp::ZFPBlockEncoder<BlockSize, Scalar, BitstreamPortal> encoder;
encoder.encode(fblock, MaxBits, vtkm::UInt32(blockIdx), stream);
encoder.encode(fblock, vtkm::Int32(MaxBits), vtkm::UInt32(blockIdx), stream);
}
};
}
......
......@@ -56,12 +56,12 @@ VTKM_EXEC inline void GatherPartial3(Scalar* q,
{
q[16 * z + 4 * y + x] = scalars.Get(offset);
}
PadBlock(q + 16 * z + 4 * y, nx, 1);
PadBlock(q + 16 * z + 4 * y, static_cast<vtkm::UInt32>(nx), 1);
}
for (x = 0; x < 4; x++)
{
PadBlock(q + 16 * z + x, ny, 4);
PadBlock(q + 16 * z + x, vtkm::UInt32(ny), 4);
}
}
......@@ -69,7 +69,7 @@ VTKM_EXEC inline void GatherPartial3(Scalar* q,
{
for (x = 0; x < 4; x++)
{
PadBlock(q + 4 * y + x, nz, 16);
PadBlock(q + 4 * y + x, vtkm::UInt32(nz), 16);
}
}
}
......@@ -171,7 +171,7 @@ public:
// std::cout<<"\n";
zfp::ZFPBlockEncoder<BlockSize, Scalar, BitstreamPortal> encoder;
encoder.encode(fblock, MaxBits, vtkm::UInt32(blockIdx), stream);
encoder.encode(fblock, vtkm::Int32(MaxBits), vtkm::UInt32(blockIdx), stream);
//blockWriter.print(0);
//blockWriter.print(1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment