Skip to content

Commit

Permalink
Squashed 'thirdParty/cuda_memtest/' changes from 3091fa6..0e27280
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Third Party authored and ax3l committed Oct 1, 2015
1 parent ac215a1 commit bdb099a
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 31 deletions.
40 changes: 40 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 18 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -69,34 +72,34 @@ 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()


################################################################################
# Build type (debug, release)
################################################################################

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")


################################################################################
Expand All @@ -109,12 +112,12 @@ 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})


################################################################################
# Install cuda_memtest
################################################################################

install(TARGETS cuda_memtest
RUNTIME DESTINATION bin)
RUNTIME DESTINATION bin)
23 changes: 13 additions & 10 deletions cuda_memtest.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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==");
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions cuda_memtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/

#ifndef __MEMTEST_H__
#define __MEMTEST_H_
#define __MEMTEST_H__

#include <stdio.h>
#include <stdint.h>
Expand Down Expand Up @@ -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); \
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bdb099a

Please sign in to comment.