From bdb099ab81f19e84e89e4c291b67ffd3ea573b65 Mon Sep 17 00:00:00 2001 From: Third Party Date: Thu, 1 Oct 2015 18:44:28 +0200 Subject: [PATCH] Squashed 'thirdParty/cuda_memtest/' changes from 3091fa6..0e27280 0e27280 Merge pull request #6 from Flamefire/dev 8c8de37 Add space 17550d1 Merge pull request #2 from ComputationalRadiationPhysics/topic-codeCleanup 278e29c Remove Unused Parameter arg 162fa90 Fix (un)singed compares and return types e843493 CMake: Add Correct Warning and Fix missing -pthread 06419c2 Merge pull request #3 from ComputationalRadiationPhysics/topic-travis 2997e4f Merge pull request #4 from ComputationalRadiationPhysics/fix-headerGuard e524a78 Add .travis.yml file for CI c821814 Fix Broken __MEMTEST_H__ Header Guard git-subtree-dir: thirdParty/cuda_memtest git-subtree-split: 0e27280cacfd77aec1fce6a7f82236239c02e5d1 --- .travis.yml | 40 ++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 33 ++++++++++++++++++--------------- cuda_memtest.cu | 23 +++++++++++++---------- cuda_memtest.h | 10 +++++----- tests.cu | 2 +- 5 files changed, 77 insertions(+), 31 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..ae90643378 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,40 @@ +language: cpp + +compiler: + - gcc + - clang + +env: + global: + - INSTALL_DIR=~/mylibs + - NVML_FILE=cuda_346.46_gdk_linux.run + - NVML_LINK=http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/ + matrix: + - USE_NVML=1 + - USE_NVML=0 + +script: + - mkdir build_tmp && cd build_tmp +# CUDA 4.0 on travis... work-around missing atomicAdd + - cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DCUDA_ARCH=sm_10 -DSAME_NVCC_FLAGS_IN_SUBPROJECTS=ON $TRAVIS_BUILD_DIR + - make + - make install + +before_script: + - sudo apt-get update -qq + - sudo apt-get install -qq build-essential + - sudo apt-get install -qq gcc-4.4 g++-4.4 + - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.4 + - gcc --version && g++ --version + - sudo apt-get install -qq nvidia-common + - sudo apt-get install -qq nvidia-current + - sudo apt-get install -qq nvidia-cuda-toolkit nvidia-cuda-dev + - if [ $USE_NVML -eq 1 ]; then wget $NVML_LINK$NVML_FILE && chmod u+x $NVML_FILE && sudo ./$NVML_FILE --silent --installdir=/ ; fi + - if [ $USE_NVML -eq 1 ]; then export CMAKE_PREFIX_PATH=/usr/src/gdk/nvml/lib/ ; fi + - sudo find /usr/ -name libcuda*.so + - sudo find /usr/ -name nvml.h + - sudo find /usr/ -name libnvidia*.so + - sudo find /usr/ -name libnvml*.so + +after_script: + - ls -halR $INSTALL_DIR diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ed7432665..e318360c78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,9 @@ find_package(CUDA REQUIRED) if(SAME_NVCC_FLAGS_IN_SUBPROJECTS) set(CUDA_ARCH sm_13 CACHE STRING "set GPU architecture" ) set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ${nvcc_flags} -arch=${CUDA_ARCH}) + if(CUDA_ARCH STREQUAL "sm_10") + add_definitions(-DSM_10=1) + endif() if(CUDA_SHOW_CODELINES) set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}" --source-in-ptx -Xcompiler -rdynamic -lineinfo) @@ -69,6 +72,12 @@ endif() ################################################################################ find_package(Threads REQUIRED) +list(APPEND LIBS ${CMAKE_THREAD_LIBS_INIT}) + +# work around for Hypnos (Ubuntu 14.04) with gcc 4.8.2 +if(NOT CMAKE_THREAD_LIBS_INIT) + list(APPEND LIBS "-pthread") +endif() ################################################################################ @@ -76,27 +85,21 @@ find_package(Threads REQUIRED) ################################################################################ option(CUDA_MEMTEST_RELEASE "disable all runtime asserts" ON) -if(PIC_RELEASE) +set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler=-pthread") +if(CUDA_MEMTEST_RELEASE) add_definitions(-DNDEBUG) - set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}" "-Xcompiler=-pthread") -else(PIC_RELEASE) +else(CUDA_MEMTEST_RELEASE) set(CMAKE_BUILD_TYPE Debug) - set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}" -g "-Xcompiler=-g,-pthread") -endif(PIC_RELEASE) + set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler=-g") + set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -g") +endif(CUDA_MEMTEST_RELEASE) ################################################################################ # Warnings ################################################################################ -set(CMAKE_CXX_FLAGS_DEFAULT "-Wall") - - -################################################################################ -# Configure include directories -################################################################################ - -set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ${INCLUDE_DIRECTORIES}) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") ################################################################################ @@ -109,7 +112,7 @@ cuda_add_executable(cuda_memtest cuda_memtest.cu ) -target_link_libraries(cuda_memtest ${LIBS} ${CUDA_CUDART_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(cuda_memtest ${LIBS} ${CUDA_CUDART_LIBRARY}) ################################################################################ @@ -117,4 +120,4 @@ target_link_libraries(cuda_memtest ${LIBS} ${CUDA_CUDART_LIBRARY} ${CMAKE_THREAD ################################################################################ install(TARGETS cuda_memtest - RUNTIME DESTINATION bin) + RUNTIME DESTINATION bin) diff --git a/cuda_memtest.cu b/cuda_memtest.cu index 3c6ab3452c..1742b58a1e 100644 --- a/cuda_memtest.cu +++ b/cuda_memtest.cu @@ -76,6 +76,7 @@ pthread_mutex_t atomic_mutex = PTHREAD_MUTEX_INITIALIZER; void run_tests(char*, unsigned int); extern void update_temperature(void); extern void allocate_small_mem(void); +volatile int active_update_temperature; typedef struct arg_s{ unsigned int device; @@ -186,19 +187,19 @@ thread_func(void* _arg) void* -temp_monitor_thread_func(void* arg) +temp_monitor_thread_func(void*) { do{ - update_temperature(); - sleep(monitor_interval); - }while(1); - + update_temperature(); + sleep(monitor_interval); + }while(active_update_temperature); + return NULL; } void list_tests_info(void) { - int i; + size_t i; for (i = 0;i < DIM(cuda_memtests); i++){ printf("%s %s\n", cuda_memtests[i].desc, cuda_memtests[i].enabled?"":" ==disabled by default=="); } @@ -319,7 +320,7 @@ main(int argc, char** argv) if (i+1 >= argc){ usage(argv); } - int idx = atoi(argv[i+1]); + size_t idx = atoi(argv[i+1]); if (idx >= DIM(cuda_memtests)){ fprintf(stderr, "Error: invalid test id\n"); usage(argv); @@ -334,7 +335,7 @@ main(int argc, char** argv) if (i+1 >= argc){ usage(argv); } - int idx = atoi(argv[i+1]); + size_t idx = atoi(argv[i+1]); if (idx >= DIM(cuda_memtests)){ fprintf(stderr, "Error: invalid test id\n"); usage(argv); @@ -345,7 +346,7 @@ main(int argc, char** argv) continue; } if (strcmp(argv[i], "--disable_all") == 0){ - int k; + size_t k; for (k=0;k < DIM(cuda_memtests);k++){ cuda_memtests[k].enabled = 0; } @@ -475,7 +476,7 @@ main(int argc, char** argv) if (strcmp(argv[i], "--stress") == 0){ //equal to "--disable_all --enable_test 10 --exit_on_error" - int k; + size_t k; for (k=0;k < DIM(cuda_memtests);k++){ cuda_memtests[k].enabled = 0; } @@ -500,6 +501,7 @@ main(int argc, char** argv) } pthread_t temp_pid; if (monitor_temp){ + active_update_temperature = 1; if (pthread_create(&temp_pid, NULL, temp_monitor_thread_func, NULL) != 0){ printf("ERROR: creating thread for temperature monitoring failed\n"); exit(ERR_GENERAL); @@ -552,6 +554,7 @@ main(int argc, char** argv) exit(ERR_BAD_STATE); } + active_update_temperature = 0; for(i=0;i < num_gpus;i++){ pthread_join(pid[i], NULL); diff --git a/cuda_memtest.h b/cuda_memtest.h index e185ba1d95..6f24e984f7 100644 --- a/cuda_memtest.h +++ b/cuda_memtest.h @@ -39,7 +39,7 @@ */ #ifndef __MEMTEST_H__ -#define __MEMTEST_H_ +#define __MEMTEST_H__ #include #include @@ -80,12 +80,12 @@ extern void get_driver_info(char* info, unsigned int len); #define PRINTF(fmt,...) do{ \ if (monitor_temp){ \ pthread_mutex_lock(&mutex); \ - printf("[%s][%s][%d][%d C]:"fmt, time_string(), hostname, gpu_idx, gpu_temp[gpu_idx],##__VA_ARGS__); \ + printf("[%s][%s][%d][%d C]:" fmt, time_string(), hostname, gpu_idx, gpu_temp[gpu_idx],##__VA_ARGS__); \ pthread_mutex_unlock(&mutex); \ } \ else{ \ pthread_mutex_lock(&mutex); \ - printf("[%s][%s][%d]:"fmt, time_string(), hostname, gpu_idx, ##__VA_ARGS__); \ + printf("[%s][%s][%d]:" fmt, time_string(), hostname, gpu_idx, ##__VA_ARGS__); \ pthread_mutex_unlock(&mutex); \ } \ fflush(stdout); \ @@ -94,10 +94,10 @@ extern void get_driver_info(char* info, unsigned int len); #define FPRINTF(fmt,...) do{ \ if (monitor_temp){ \ - fprintf(stderr, "[%s][%s][%d][%d C]:"fmt, time_string(), hostname, gpu_idx, gpu_temp[gpu_idx],##__VA_ARGS__); \ + fprintf(stderr, "[%s][%s][%d][%d C]:" fmt, time_string(), hostname, gpu_idx, gpu_temp[gpu_idx],##__VA_ARGS__); \ } \ else{ \ - fprintf(stderr, "[%s][%s][%d]:"fmt, time_string(), hostname, gpu_idx, ##__VA_ARGS__); \ + fprintf(stderr, "[%s][%s][%d]:" fmt, time_string(), hostname, gpu_idx, ##__VA_ARGS__); \ } \ fflush(stderr); \ } while(0) diff --git a/tests.cu b/tests.cu index fc5a88ae48..af3159fdb1 100644 --- a/tests.cu +++ b/tests.cu @@ -588,7 +588,7 @@ test0(char* ptr, unsigned int tot_num_blocks) kernel_test0_global_read<<<1, 1>>>(ptr, end_ptr, err_count, err_addr, err_expect, err_current, err_second_read); SYNC_CUERR; error_checking("test0 on global address", 0); - for(int ite = 0;ite < num_iterations; ite++){ + for(unsigned int ite = 0;ite < num_iterations; ite++){ for (i=0;i < tot_num_blocks; i+= GRIDSIZE){ dim3 grid; grid.x= GRIDSIZE;