mirror of https://github.com/intel/intel-qs.git
Code cleaning to eliminate warnings from clang compiler
Mostly, warning that operator << has lower precedence than operator +: 1UL << c + 1UL ----> 1UL << (c + 1UL)
This commit is contained in:
parent
c741d706f7
commit
2640d573eb
|
@ -60,6 +60,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel
|
||||
#pragma omp master
|
||||
{
|
||||
|
@ -67,6 +68,7 @@ int main(int argc, char **argv)
|
|||
if (myrank==0)
|
||||
fprintf(stdout, "OMP number of threads = %d \n", nthreads);
|
||||
}
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -53,7 +53,10 @@ int main(int argc, char **argv)
|
|||
#pragma omp parallel
|
||||
#pragma omp master
|
||||
{
|
||||
int nthreads = omp_get_num_threads();
|
||||
int nthreads = 1;
|
||||
#ifdef _OPENMP
|
||||
nthreads = omp_get_num_threads();
|
||||
#endif
|
||||
fprintf(stdout, "OMP number of threads = %d \n", nthreads);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ class ChiMatrix : public TinyMatrix<ValueType, M, M, align>
|
|||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Return non-constant pointer to data_.
|
||||
ValueType * GetPtrToData () {return &data_[0][0];};
|
||||
ValueType * GetPtrToData () {return &(this->data_[0][0]);};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -323,7 +323,7 @@ class ChiMatrix : public TinyMatrix<ValueType, M, M, align>
|
|||
if ( (i==1 || i==3) && (j==1 || j==3) )
|
||||
assert(this->data_[i][j]==value_type(0.5,0));
|
||||
else
|
||||
assert(std::norm(this->data_[i][j]==0));
|
||||
assert(std::norm(this->data_[i][j])==0);
|
||||
}
|
||||
// Set eigensystem.
|
||||
std::vector<value_type> array_zeros(M, 0);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#message(STATUS "Binary dir ${CMAKE_BINARY_DIR} , and project_bin ${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
# Download and unpack eigen library at configure time.
|
||||
cmake_minimum_required(VERSION 3.15.2)
|
||||
cmake_minimum_required(VERSION 3.12.0)
|
||||
include(${CMAKE_MODULE_PATH}/ExternalProject.cmake)
|
||||
ExternalProject_Add(deps-eigen
|
||||
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
|
||||
|
|
|
@ -328,10 +328,10 @@ void Loop_DN(std::size_t gstart, std::size_t gend, std::size_t pos,
|
|||
frac_of_state_accessed = 1.;
|
||||
label = "general";
|
||||
|
||||
if((gend - gstart) / (1L << pos+1L) >= nthreads)
|
||||
if((gend - gstart) / (1L << (pos+1L)) >= nthreads)
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for(std::size_t group = gstart; group < gend; group += (1L << pos + 1L))
|
||||
for(std::size_t group = gstart; group < gend; group += (1L << (pos + 1L)))
|
||||
{
|
||||
for(std::size_t ind0 = group; ind0 < group + (1L << pos); ind0++)
|
||||
{
|
||||
|
@ -345,7 +345,7 @@ void Loop_DN(std::size_t gstart, std::size_t gend, std::size_t pos,
|
|||
}
|
||||
else
|
||||
{
|
||||
for(std::size_t group = gstart; group < gend; group += (1L << pos + 1))
|
||||
for(std::size_t group = gstart; group < gend; group += (1L << (pos + 1)))
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for(std::size_t ind0 = group; ind0 < group + (1L << pos); ind0++)
|
||||
|
|
|
@ -160,8 +160,8 @@ double QubitRegister<Type>::HP_Distrpair(unsigned control_position, unsigned tar
|
|||
{
|
||||
assert( lcl_chunk <= (UL(1)<<C) );
|
||||
assert( (UL(1)<<C) % lcl_chunk==0 );
|
||||
for(size_t gc = (UL(1)<<C); gc < lcl_size_half; gc += (UL(1)<<C+1))
|
||||
for(size_t c = gc+0; c < gc+(UL(1)<<C); c += lcl_chunk)
|
||||
for (size_t gc = (UL(1)<<C); gc < lcl_size_half; gc += (UL(1)<<(C+1)))
|
||||
for (size_t c = gc+0; c < gc+(UL(1)<<C); c += lcl_chunk)
|
||||
{
|
||||
if (itask == myrank) // this is itask
|
||||
{
|
||||
|
@ -312,16 +312,16 @@ bool QubitRegister<Type>::ApplyControlled1QubitGate_helper(unsigned control_qubi
|
|||
if (specialize2 && (spec != GateSpec2Q::None))
|
||||
{
|
||||
Loop_TN(state,
|
||||
sind, eind, 1UL<<C+1UL,
|
||||
1UL<<C, 1UL<<C+1UL, 1UL<<T+1UL,
|
||||
0L, 1UL<<T, 1UL<<T, spec, timer, angle);
|
||||
sind, eind, 1UL<<(C+1UL),
|
||||
1UL<<C, 1UL<<(C+1UL), 1UL<<(T+1UL),
|
||||
0L, 1UL<<T, 1UL<<T, spec, timer, angle);
|
||||
}
|
||||
else
|
||||
{
|
||||
Loop_TN(state,
|
||||
sind, eind, 1UL<<C+1UL,
|
||||
1UL<<C, 1UL<<C+1UL, 1UL<<T+1UL,
|
||||
0L, 1UL<<T, 1UL<<T , m, specialize, timer);
|
||||
sind, eind, 1UL<<(C+1UL),
|
||||
1UL<<C, 1UL<<(C+1UL), 1UL<<(T+1UL),
|
||||
0L, 1UL<<T, 1UL<<T , m, specialize, timer);
|
||||
}
|
||||
HasDoneWork = true;
|
||||
}
|
||||
|
@ -331,17 +331,17 @@ bool QubitRegister<Type>::ApplyControlled1QubitGate_helper(unsigned control_qubi
|
|||
if (specialize2 && (spec != GateSpec2Q::None))
|
||||
{
|
||||
Loop_TN(state,
|
||||
sind, eind, 1UL<<T+1UL,
|
||||
0L, 1UL<<T, 1UL<<C+1UL,
|
||||
1UL<<C, 1UL<<C+1UL, 1UL<<T, spec, timer, angle
|
||||
sind, eind, 1UL<<(T+1UL),
|
||||
0L, 1UL<<T, 1UL<<(C+1UL),
|
||||
1UL<<C, 1UL<<(C+1UL), 1UL<<T, spec, timer, angle
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Loop_TN(state,
|
||||
sind, eind, 1UL<<T+1UL,
|
||||
0L, 1UL<<T, 1UL<<C+1UL,
|
||||
1UL<<C, 1UL<<C+1UL, 1UL<<T , m, specialize, timer);
|
||||
sind, eind, 1UL<<(T+1UL),
|
||||
0L, 1UL<<T, 1UL<<(C+1UL),
|
||||
1UL<<C, 1UL<<(C+1UL), 1UL<<T , m, specialize, timer);
|
||||
}
|
||||
HasDoneWork = true;
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ if (beginning != end) printf( (buffer.str()).c_str() );
|
|||
// Balanced superposition of all basis states.
|
||||
else if (style == "++++")
|
||||
{
|
||||
Type amplitude = {1./std::sqrt( GlobalSize() ),0.};
|
||||
Type amplitude = {BaseType(1./std::sqrt( GlobalSize() )), 0.};
|
||||
std::size_t lcl = LocalSize();
|
||||
#pragma omp parallel for
|
||||
for (std::size_t i = 0; i < lcl; i++)
|
||||
|
|
|
@ -13,12 +13,12 @@ namespace iqs {
|
|||
#define PARALLEL_FOR_2D \
|
||||
_Pragma("omp parallel for collapse(2)") \
|
||||
for(std::size_t group = gstart; group < gend; \
|
||||
group += (1L << pos + 1L)) \
|
||||
group += (1L << (pos + 1L))) \
|
||||
for(std::size_t ind0 = 0; ind0 < (1L << pos); ind0++)
|
||||
|
||||
#define SERIAL_FOR_2D \
|
||||
for(std::size_t group = gstart; group < gend; \
|
||||
group += (1L << pos + 1L)) \
|
||||
group += (1L << (pos + 1L))) \
|
||||
for(std::size_t ind0 = 0; ind0 < (1L << pos); ind0++)
|
||||
|
||||
#define PARALLEL_FOR_3D \
|
||||
|
|
|
@ -16,7 +16,7 @@ double time_in_seconds(void)
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void iqs::WhatCompileDefinitions()
|
||||
void WhatCompileDefinitions()
|
||||
{
|
||||
std::cout << "Compiler flags:\n"
|
||||
|
||||
|
|
|
@ -338,7 +338,7 @@ namespace utest
|
|||
printf("name::%s %s\n", name.c_str(), p.GetMapStr().c_str());
|
||||
printf("data program state[data]\n");
|
||||
for (std::size_t i = 0; i < state.size(); i++) {
|
||||
printf("%i %s {%lf %lf}\n", i, p.data2program(i).c_str(), real(state[i]), imag(state[i]));
|
||||
printf("%zu %s {%lf %lf}\n", i, p.data2program(i).c_str(), real(state[i]), imag(state[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ int main(int argc, char **argv)
|
|||
M_PI-pi,\
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(diff).count());
|
||||
#else
|
||||
printf("This program was compiled for execution without OpenMP.\m");
|
||||
printf("This program was compiled for execution without OpenMP.\n");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue