Skip to content

Commit

Permalink
added some cuda stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
studouglas committed Nov 16, 2015
1 parent 497e0e7 commit bea3b45
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ G4STORK/SourceFiles

geant4.10.00.p02/tmp
geant4.10.00.p02-build/*
geant4.10.00.p02-build2
geant4.10.00.p02-install/*
geant4.10.00.p02/examples/*
!geant4.10.00.p02/examples/basic/B1
Expand Down
7 changes: 4 additions & 3 deletions CUDA-test/CMakeLists.txt → CUDA-test/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
cmake_minimum_required (VERSION 2.8)
project(TestingCudaSquareArray)
project(MainExe)

find_package (CUDA REQUIRED)

include_directories(/usr/local/cuda/include)

cuda_add_executable (TestingCudaSquareArray DeviceMain.h DeviceMain.cu HostMain.cpp)
cuda_add_library (TestingCudaSquareArrayLib DeviceMain.h DeviceMain.cu)
add_executable (MainExe HostMain.cpp)

LIST(APPEND CMAKE_CXX_FLAGS "-std=c++0x -O3 -ffast-math -Wall")

LIST(APPEND CUDA_NVCC_FLAGS --compiler-options -fno-strict-aliasing -lineinfo -use_fast_math -Xptxas -dlcm=cg)
LIST(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_30,code=sm_30)

target_link_libraries(TestingCudaSquareArray /usr/local/cuda/lib/libcudart_static.a)
target_link_libraries(MainExe TestingCudaSquareArrayLib /usr/local/cuda/lib/libcudart_static.a)
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 0 additions & 16 deletions geant4.10.00.p02/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,6 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
#
project(Geant4)


#----------------------------------------------------------------------------
if (GEANT4_CUDA_ENABLED)
find_package(CUDA)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_20,code=sm_20)
cuda_compile(VECTOR_O source/cuda/CUDA_G4NeutronHPVector.cu)
cuda_add_executable(
cuda_g4neutronhpvector
source/cuda/CUDA_G4NeutronHPVector.cu
source/cuda/CUDA_G4NeutronHPVector.h
source/processes/hadronic/models/neutron_hp/src/G4NeutronHPVector.cc
source/processes/hadronic/models/neutron_hp/include/G4NeutronHPVector.hh)
endif()
#----------------------------------------------------------------------------


#----------------------------------------------------------------------------
# - Prepend our own CMake Modules to the search path
# This allows us to customize, add, and factor out functionality
Expand Down
1 change: 0 additions & 1 deletion geant4.10.00.p02/source/cuda/CUDA_TestSquareArray.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#
#------------------------------------------------------------------------------

add_subdirectory(cuda)

if(GEANT4_BUILD_GRANULAR_LIBS)
include(Geant4MacroLibraryTargets)
GEANT4_GRANULAR_LIBRARY_TARGET(COMPONENT sources.cmake)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required (VERSION 2.8)

find_package (CUDA REQUIRED)

include_directories(/usr/local/cuda/include)

cuda_add_library (CUDA_G4NeutronHPVector SHARED CUDA_G4NeutronHPVector.h CUDA_G4NeutronHPVector.cu)

#LIST(APPEND CMAKE_CXX_FLAGS "-std=c++0x -O3 -ffast-math -Wall")
LIST(APPEND CUDA_NVCC_FLAGS --compiler-options -fno-strict-aliasing -lineinfo -use_fast_math -Xptxas -dlcm=cg)
LIST(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_30,code=sm_30)

#target_link_libraries(Geant4 CUDA_G4NeutronHPVector /usr/local/cuda/lib/libcudart_static.a)
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ float squareArray(int N) {
cudaFree(a_d);

return a_h[N-1];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
float squareArray(int N);
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
#include "G4NeutronHPVector.hh"
#include "G4SystemOfUnits.hh"

#define CUDA_ENABLED 1
#if CUDA_ENABLED
#include "CUDA_G4NeutronHPVector.h"
#endif
//#define CUDA_ENABLED 1
//#if CUDA_ENABLED
//#include "CUDA_G4NeutronHPVector.h"
//#endif

// if the ranges do not match, constant extrapolation is used.
G4NeutronHPVector & operator + (G4NeutronHPVector & left, G4NeutronHPVector & right)
Expand Down Expand Up @@ -291,10 +291,10 @@
void G4NeutronHPVector::ThinOut(G4double precision)
{

#if CUDA_ENABLED
float result = squareArray(100);
G4cout <<"G4NeutronHPVector::ThinOut test on GPU result: "<< result << G4endl;
#endif
//#if CUDA_ENABLED
// float result = squareArray(100);
// G4cout <<"G4NeutronHPVector::ThinOut test on GPU result: "<< result << G4endl;
//#endif

// anything in there?
if(GetVectorLength()==0) return;
Expand Down

0 comments on commit bea3b45

Please sign in to comment.