Skip to content

Commit

Permalink
Cleaning up the pedantic compiler flags
Browse files Browse the repository at this point in the history
And resolving pedantic compiler warnings.
  • Loading branch information
khuck committed Mar 26, 2020
1 parent d037ea4 commit c002fd4
Show file tree
Hide file tree
Showing 74 changed files with 473 additions and 255 deletions.
75 changes: 32 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ if (${CMAKE_MAJOR_VERSION} GREATER 2)
endif()
endif()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
message(FATAL_ERROR "GCC version must be at least 4.9!")
endif()
endif()

#if (${CMAKE_MAJOR_VERSION} GREATER 2)
# if (${CMAKE_MAJOR_VERSION} GREATER 1)
# cmake_policy(SET CMP0054 OLD)
Expand Down Expand Up @@ -201,51 +208,33 @@ if (DEFINED APEX_SANITIZE_THREAD AND APEX_SANITIZE_THREAD)
endif (DEFINED APEX_SANITIZE_THREAD AND APEX_SANITIZE_THREAD)

# set debug options
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${APEX_SANITIZE_OPTIONS} -DAPEX_ERROR_HANDLING")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${APEX_SANITIZE_OPTIONS} -DAPEX_ERROR_HANDLING")

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -march=native -DNDEBUG -Wno-deprecated")
set(CMAKE_C_FLAGS_RELEASE "-Ofast -march=native -DNDEBUG -Wno-deprecated")
# using Clang
set(CXX_PEDANTIC_COMPILER_WARNINGS "-Werror -Wsometimes-uninitialized -fdiagnostics-show-option -Wall -Wcast-align -Wcast-qual -Werror=format -Werror=missing-braces -Werror=parentheses -Werror=reorder -Werror=return-type -Werror=sequence-point -Werror=sign-compare -Werror=uninitialized -Werror=vla -Wextra -Wformat=2 -Winit-self -Wno-attributes -Wno-cast-align -Wno-delete-non-virtual-dtor -Wno-format-nonliteral -Wno-ignored-qualifiers -Wno-sign-promo -Wno-strict-aliasing -Wno-unused-parameter -Wno-unused-variable -Wno-unused-local-typedefs -Wno-unused-parameter ")
set(C_PEDANTIC_COMPILER_WARNINGS "-Werror -Wsometimes-uninitialized -fdiagnostics-show-option -Wall -Wcast-align -Wcast-qual -Werror=format -Werror=missing-braces -Werror=parentheses -Werror=reorder -Werror=return-type -Werror=sequence-point -Werror=sign-compare -Werror=uninitialized -Werror=vla -Wextra -Wformat=2 -Winit-self -Wno-attributes -Wno-cast-align -Wno-format-nonliteral -Wno-ignored-qualifiers -Wno-strict-aliasing -Wno-unused-parameter -Wno-unused-variable -Wno-unused-local-typedefs -Wno-unused-parameter ")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 ${CXX_PEDANTIC_COMPILER_WARNINGS} ${APEX_SANITIZE_OPTIONS} -DAPEX_ERROR_HANDLING")
set(CMAKE_C_FLAGS_DEBUG "-g -O0 ${C_PEDANTIC_COMPILER_WARNINGS} ${APEX_SANITIZE_OPTIONS} -DAPEX_ERROR_HANDLING")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
message(FATAL_ERROR "GCC version must be at least 4.9!")
endif()
# ---------------------------------------------------
# Set pedantic error flags if available
# ---------------------------------------------------
include(CheckCXXCompilerFlag)

set(CXX_PEDANTIC_COMPILER_WARNINGS "-fdiagnostics-show-option -Wall -Wmaybe-uninitialized -Wcast-align -Wcast-qual -Wdouble-promotion -Werror=format -Werror=missing-braces -Werror=parentheses -Werror=reorder -Werror=return-type -Werror=sequence-point -Werror=sign-compare -Werror=trampolines -Werror=uninitialized -Werror=vla -Wextra -Wformat=2 -Winit-self -Wno-attributes -Wno-cast-align -Wno-delete-non-virtual-dtor -Wno-format-nonliteral -Wno-ignored-qualifiers -Wno-sign-promo -Wno-strict-aliasing -Wno-sync-nand -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wno-unused-local-typedefs -Wno-unused-parameter ")
set(C_PEDANTIC_COMPILER_WARNINGS "-fdiagnostics-show-option -Wall -Wmaybe-uninitialized -Wcast-align -Wcast-qual -Wdouble-promotion -Werror=format -Werror=missing-braces -Werror=parentheses -Werror=reorder -Werror=return-type -Werror=sequence-point -Werror=sign-compare -Werror=trampolines -Werror=uninitialized -Werror=vla -Wextra -Wformat=2 -Winit-self -Wno-attributes -Wno-cast-align -Wno-format-nonliteral -Wno-ignored-qualifiers -Wno-strict-aliasing -Wno-sync-nand -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wno-unused-local-typedefs -Wno-unused-parameter ")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 ${CXX_PEDANTIC_COMPILER_WARNINGS} ${APEX_SANITIZE_OPTIONS} -DAPEX_ERROR_HANDLING")
set(CMAKE_C_FLAGS_DEBUG "-g -O0 ${C_PEDANTIC_COMPILER_WARNINGS} ${APEX_SANITIZE_OPTIONS} -DAPEX_ERROR_HANDLING")
# -march=native is broken on sandybridge architectures.
execute_process(COMMAND lscpu COMMAND grep Model: OUTPUT_VARIABLE CPUMODEL_STRING)
string(REPLACE " " ";" CPUMODEL_LIST ${CPUMODEL_STRING})
list(LENGTH CPUMODEL_LIST CPUMODEL_LENGTH)
math(EXPR CPUMODEL_LENGTH "${CPUMODEL_LENGTH} - 1")
list(GET CPUMODEL_LIST ${CPUMODEL_LENGTH} CPUMODEL)
# message(STATUS "CPU Model: ${CPUMODEL}")
if(CPUMODEL EQUAL 63)
message(STATUS "Detected Sandybridge CPU - using special optimization flags")
SET(CMAKE_CXX_FLAGS_RELEASE "-Ofast -march=corei7-avx -mtune=corei7-avx -mno-avx -mno-aes -flto -DNDEBUG -Wno-deprecated")
SET(CMAKE_C_FLAGS_RELEASE "-Ofast -march=corei7-avx -mtune=corei7-avx -mno-avx -mno-aes -flto -DNDEBUG -Wno-deprecated")
else()
SET(CMAKE_CXX_FLAGS_RELEASE "-Ofast -march=native -flto -DNDEBUG -Wno-deprecated")
SET(CMAKE_C_FLAGS_RELEASE "-Ofast -march=native -flto -DNDEBUG -Wno-deprecated")
endif()
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} -flto")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# using Intel C++
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 ")
set(CMAKE_C_FLAGS_DEBUG "-g -O0 ")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -march=native -ipo -DNDEBUG -Wno-deprecated")
set(CMAKE_C_FLAGS_RELEASE "-Ofast -march=native -ipo -DNDEBUG -Wno-deprecated")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} -ipo")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# using Visual Studio C++
endif()
function(enable_cxx_compiler_flag_if_supported flag)
string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" flag_already_set)
if(flag_already_set EQUAL -1)
check_cxx_compiler_flag("${flag}" flag_supported)
if(flag_supported)
message(INFO " ${flag} supported by compiler, enabling it")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
endif()
unset(flag_supported CACHE)
endif()
endfunction()

# example usage
enable_cxx_compiler_flag_if_supported("-Wall")
enable_cxx_compiler_flag_if_supported("-Werror")
enable_cxx_compiler_flag_if_supported("-Wextra")
enable_cxx_compiler_flag_if_supported("-Wpedantic")
enable_cxx_compiler_flag_if_supported("-pedantic")
# ---------------------------------------------------

# The version number.
set (APEX_VERSION_MAJOR 2)
Expand Down
31 changes: 23 additions & 8 deletions etc/buildbot.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash
#set -x # echo all commands

source /usr/local/spack/share/spack/setup-env.sh
spack load cmake
host=`hostname`
if [ "$host" == "ktau" ] ; then
source /usr/local/spack/share/spack/setup-env.sh
spack load cmake
fi

my_readlink()
{
Expand All @@ -19,7 +22,7 @@ my_readlink()
TARGET=$(basename "$TARGET")
done

# Compute the canonicalized name by finding the physical path
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
DIR=`pwd -P`
RESULT="$DIR/$TARGET"
Expand All @@ -44,6 +47,15 @@ yes_ompt=" -DUSE_OMPT=TRUE -DOMPT_ROOT=/usr/local/ompt/5.0"
yes_mpi=" -DUSE_MPI=TRUE"
yes_papi=" -DUSE_PAPI=TRUE -DPAPI_ROOT=/usr"
yes_tau=" -DUSE_TAU=TRUE -DTAU_ROOT=/usr/local/tau/git -DTAU_ARCH=x86_64 -DTAU_OPTIONS=-pthread"
if [ "$host" == "delphi" ] ; then
yes_bfd=" -DUSE_BFD=TRUE -DBFD_ROOT=/usr/local/packages/binutils/2.27"
yes_malloc=" -DUSE_JEMALLOC=TRUE -DJEMALLOC_ROOT=/usr/local/packages/jemalloc/5.0.1-gcc"
yes_ah=" -DUSE_ACTIVEHARMONY=TRUE -DACTIVEHARMONY_ROOT=/usr/local/packages/activeharmony/4.6.0-gcc -DUSE_PLUGINS=TRUE"
yes_otf=" -DUSE_OTF2=TRUE -DOTF2_ROOT=/usr/local/packages/otf2/2.1"
yes_ompt=" -DUSE_OMPT=TRUE -DOMPT_ROOT=/usr/local/packages/llvm-openmp/2020-03-25"
yes_papi=" -DUSE_PAPI=TRUE -DPAPI_ROOT=/usr/local/packages/papi/5.6.0"
yes_tau=" -DUSE_TAU=TRUE "
fi

# set defaults
build="default"
Expand All @@ -56,12 +68,15 @@ sanitize=""
ncores=2
osname=`uname`
if [ ${osname} == "Darwin" ]; then
ncores=`sysctl -n hw.ncpu`
export CC=`which clang`
export CXX=`which clang++`
#cmake_generator="-G Xcode"
ncores=`sysctl -n hw.ncpu`
export CC=`which clang`
export CXX=`which clang++`
#cmake_generator="-G Xcode"
else
ncores=`nproc --all`
# Get the true number of total cores, not threads.
ncoresper=`lscpu | grep -E '^Core' | awk '{print $NF}'`
nsockets=`lscpu | grep -E '^Socket' | awk '{print $NF}'`
let ncores=$ncoresper*$nsockets
fi

echo "Num parallel builds: $ncores"
Expand Down
48 changes: 24 additions & 24 deletions src/ITTNotify/ittnotify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,43 +146,43 @@ void __itt_thread_set_name (const char * name) {
apex::register_thread(string(name));
}

void __itt_sync_create(void*, const char*, const char*, int) { APEX_TRACER };
void __itt_sync_rename(void*, const char*) { APEX_TRACER };
void __itt_sync_prepare(void*) { APEX_TRACER };
void __itt_sync_acquired(void*) { APEX_TRACER };
void __itt_sync_cancel(void*) { APEX_TRACER };
void __itt_sync_releasing(void*) { APEX_TRACER };
void __itt_sync_destroy(void*) { APEX_TRACER };
void __itt_thread_ignore() { APEX_TRACER };
void __itt_sync_create(void*, const char*, const char*, int) { APEX_TRACER }
void __itt_sync_rename(void*, const char*) { APEX_TRACER }
void __itt_sync_prepare(void*) { APEX_TRACER }
void __itt_sync_acquired(void*) { APEX_TRACER }
void __itt_sync_cancel(void*) { APEX_TRACER }
void __itt_sync_releasing(void*) { APEX_TRACER }
void __itt_sync_destroy(void*) { APEX_TRACER }
void __itt_thread_ignore() { APEX_TRACER }
__itt_heap_function __itt_heap_function_create(const char*, const char*) {
APEX_TRACER return nullptr; };
APEX_TRACER return nullptr; }
void __itt_heap_allocate_begin(__itt_heap_function, std::size_t, int) {
APEX_TRACER };
APEX_TRACER }
void __itt_heap_allocate_end(__itt_heap_function, void**, std::size_t, int) {
APEX_TRACER };
void __itt_heap_free_begin(__itt_heap_function, void*) { APEX_TRACER };
void __itt_heap_free_end(__itt_heap_function, void*) { APEX_TRACER };
APEX_TRACER }
void __itt_heap_free_begin(__itt_heap_function, void*) { APEX_TRACER }
void __itt_heap_free_end(__itt_heap_function, void*) { APEX_TRACER }
void __itt_heap_reallocate_begin(__itt_heap_function, void*, std::size_t, int)
{ APEX_TRACER };
{ APEX_TRACER }
void __itt_heap_reallocate_end(__itt_heap_function a, void* b, void** c,
std::size_t d, int e) { APEX_TRACER ;APEX_UNUSED(a); APEX_UNUSED(b);
APEX_UNUSED(c); APEX_UNUSED(d); APEX_UNUSED(e); };
void __itt_heap_internal_access_begin() { APEX_TRACER };
void __itt_heap_internal_access_end() { APEX_TRACER };
APEX_UNUSED(c); APEX_UNUSED(d); APEX_UNUSED(e); }
void __itt_heap_internal_access_begin() { APEX_TRACER }
void __itt_heap_internal_access_end() { APEX_TRACER }

__itt_mark_type __itt_mark_create(char const* name) { APEX_TRACER ;
APEX_UNUSED(name); return 0; };
APEX_UNUSED(name); return 0; }
int __itt_mark_off(__itt_mark_type mark) { APEX_TRACER ; APEX_UNUSED(mark);
return 0; };
return 0; }
int __itt_mark(__itt_mark_type mark, char const* par) { APEX_TRACER ;
APEX_UNUSED(mark); APEX_UNUSED(par); return 0; };
__itt_caller __itt_stack_caller_create() { APEX_TRACER return nullptr; };
APEX_UNUSED(mark); APEX_UNUSED(par); return 0; }
__itt_caller __itt_stack_caller_create() { APEX_TRACER return nullptr; }
void __itt_stack_callee_enter(__itt_caller ctx) { APEX_TRACER ;
APEX_UNUSED(ctx); };
APEX_UNUSED(ctx); }
void __itt_stack_callee_leave(__itt_caller ctx) { APEX_TRACER ;
APEX_UNUSED(ctx); };
APEX_UNUSED(ctx); }
void __itt_stack_caller_destroy(__itt_caller ctx) { APEX_TRACER ;
APEX_UNUSED(ctx); };
APEX_UNUSED(ctx); }

// assign some function pointers
#if defined(_WIN32) || defined(_WIN64)
Expand Down
4 changes: 4 additions & 0 deletions src/apex/apex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ inline std::shared_ptr<task_wrapper> _new_task(
task_identifier * id,
const uint64_t task_id,
const std::shared_ptr<task_wrapper> parent_task, apex* instance) {
APEX_UNUSED(instance);
std::shared_ptr<task_wrapper> tt_ptr = make_shared<task_wrapper>();
tt_ptr->task_id = id;
// if not tracking dependencies, don't save the parent
Expand Down Expand Up @@ -1660,6 +1661,8 @@ apex_policy_handle * sample_runtime_counter(unsigned long period, const
});
}
#else
APEX_UNUSED(period);
APEX_UNUSED(counter_name);
std::cerr <<
"WARNING: Runtime counter sampling is not implemented for your runtime"
<< std::endl;
Expand Down Expand Up @@ -1785,6 +1788,7 @@ void send (uint64_t tag, uint64_t size, uint64_t target) {

void recv (uint64_t tag, uint64_t size, uint64_t source_rank, uint64_t
source_thread) {
APEX_UNUSED(source_thread);
// if APEX is disabled, do nothing.
if (apex_options::disable() == true) { return ; }
// if APEX is suspended, do nothing.
Expand Down
27 changes: 23 additions & 4 deletions src/apex/apex_ompt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ void apex_ompt_stop(ompt_data_t * ompt_data) {

/* Event #1, thread begin */
extern "C" void apex_thread_begin(
ompt_thread_t thread_type, /* type of thread */
ompt_data_t *thread_data /* data of thread */
) {
ompt_thread_t thread_type, /* type of thread */
ompt_data_t *thread_data /* data of thread */)
{
APEX_UNUSED(thread_data);
{
std::unique_lock<std::mutex> l(apex_apex_threadid_mutex);
apex_threadid = apex_numthreads++;
Expand Down Expand Up @@ -161,6 +162,10 @@ static void apex_parallel_region_begin (
int flags, /* flags */
const void *codeptr_ra /* return address of runtime call */
) {
APEX_UNUSED(encountering_task_data);
APEX_UNUSED(encountering_task_frame);
APEX_UNUSED(requested_team_size);
APEX_UNUSED(flags);
char regionIDstr[128] = {0};
sprintf(regionIDstr, "OpenMP Parallel Region: UNRESOLVED ADDR %p", codeptr_ra);
apex_ompt_start(regionIDstr, parallel_data, nullptr, true);
Expand All @@ -177,6 +182,9 @@ static void apex_parallel_region_end (
int flags, /* flags */
const void *codeptr_ra /* return address of runtime call */
) {
APEX_UNUSED(encountering_task_data);
APEX_UNUSED(flags);
APEX_UNUSED(codeptr_ra);
//printf("%llu: Parallel Region End parent: %p, apex_parent: %p, region:
//%p, apex_region: %p\n", apex_threadid, encountering_task_data,
//encountering_task_data->ptr, parallel_data, parallel_data->ptr);
Expand All @@ -193,6 +201,9 @@ extern "C" void apex_task_create (
int has_dependences, /* created task has dependences */
const void *codeptr_ra /* return address of runtime call */
) {
APEX_UNUSED(encountering_task_frame);
APEX_UNUSED(has_dependences);
APEX_UNUSED(codeptr_ra);
char * type_str;
static const char * initial_str = "OpenMP Initial Task";
static const char * implicit_str = "OpenMP Implicit Task";
Expand Down Expand Up @@ -291,6 +302,8 @@ extern "C" void apex_implicit_task(
unsigned int team_size, /* team size */
unsigned int thread_num /* thread number of calling thread */
) {
APEX_UNUSED(team_size);
APEX_UNUSED(thread_num);
if (endpoint == ompt_scope_begin) {
apex_ompt_start("OpenMP Implicit Task", task_data, parallel_data,
false);
Expand Down Expand Up @@ -457,6 +470,7 @@ extern "C" void apex_ompt_work (
uint64_t count, /* quantity of work */
const void *codeptr_ra /* return address of runtime call */
) {
APEX_UNUSED(count);

char * tmp_str;
static const char * loop_str = "Loop";
Expand Down Expand Up @@ -595,6 +609,7 @@ extern "C" void apex_ompt_flush (
ompt_data_t *thread_data, /* data of thread */
const void *codeptr_ra /* return address of runtime call */
) {
APEX_UNUSED(thread_data);
if (codeptr_ra != nullptr) {
char regionIDstr[128] = {0};
sprintf(regionIDstr, "OpenMP Flush: UNRESOLVED ADDR %p", codeptr_ra);
Expand Down Expand Up @@ -711,6 +726,7 @@ extern "C" {
int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,
ompt_data_t* tool_data) {
APEX_UNUSED(initial_device_num);
APEX_UNUSED(tool_data);
{
std::unique_lock<std::mutex> l(apex_apex_threadid_mutex);
apex_threadid = apex_numthreads++;
Expand Down Expand Up @@ -865,12 +881,15 @@ int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,

void ompt_finalize(ompt_data_t* tool_data)
{
APEX_UNUSED(tool_data);
printf("OpenMP runtime is shutting down...\n");
apex::finalize();
}

ompt_start_tool_result_t * ompt_start_tool(
unsigned int omp_version, const char *runtime_version) {
APEX_UNUSED(omp_version);
APEX_UNUSED(runtime_version);
static ompt_start_tool_result_t result;
result.initialize = &ompt_initialize;
result.finalize = &ompt_finalize;
Expand All @@ -879,4 +898,4 @@ ompt_start_tool_result_t * ompt_start_tool(
return &result;
}

}; // extern "C"
} // extern "C"
2 changes: 1 addition & 1 deletion src/apex/apex_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ namespace apex
free (_##member_variable);
FOREACH_EXTERNAL_STRING_OPTION(apex_macro)
#undef apex_macro
};
}

apex_options::~apex_options(void) {
#define apex_macro(name, member_variable, type, default_value) \
Expand Down
8 changes: 6 additions & 2 deletions src/apex/apex_policies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,8 +1262,12 @@ tuning_session) {

#else
inline void __apex_active_harmony_setup(shared_ptr<apex_tuning_session>
tuning_session) { }
inline void __apex_active_harmony_setup(apex_tuning_session * tuning_session) { }
tuning_session) {
APEX_UNUSED(tuning_session);
}
inline void __apex_active_harmony_setup(apex_tuning_session * tuning_session) {
APEX_UNUSED(tuning_session);
}
inline void __active_harmony_throughput_setup(int num_inputs, long ** inputs,
long * mins, long * maxs, long * steps) {
APEX_UNUSED(num_inputs);
Expand Down
1 change: 1 addition & 0 deletions src/apex/concurrency_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ void concurrency_handler::on_reset(task_identifier * id) {
}

void concurrency_handler::on_shutdown(shutdown_event_data &data) {
APEX_UNUSED(data);
_terminate = true; // because there are crashes
cancel();
}
Expand Down
Loading

0 comments on commit c002fd4

Please sign in to comment.