Commit 5ad9b569 authored by Berrill, Mark's avatar Berrill, Mark
Browse files

Creating SYCL port. Note that this required incompatible changes so it is in...

Creating SYCL port.  Note that this required incompatible changes so it is in a seperate branch until I can resolve this
parent 0aa84331
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ rm -rf CMake*
cmake                                   \
   -D CMAKE_BUILD_TYPE=Release          \
   -D CMAKE_CXX_COMPILER=mpic++         \
   -D CMAKE_CXX_STANDARD=11             \
   -D CMAKE_CXX_STANDARD=14             \
   -D USE_OPENACC=0                     \
   -D USE_OPENMP=1                      \
   -D USE_KOKKOS=0                      \
@@ -15,5 +15,8 @@ cmake \
      -D KOKKOS_WRAPPER=${KOKKOS_DIR}/nvcc_wrapper \
   -D USE_CUDA=1                        \
      -D CUDA_FLAGS="-arch sm_30"       \
   -D USE_COMPUTE_CPP=1                 \
      -D ComputeCpp_DIR=/packages/ComputeCpp/ComputeCpp-CE-1.1.4-Ubuntu-16.04-x86_64 \
      -D COMPUTECPP_BITCODE=ptx64       \
   ../src
+21 −3
Original line number Diff line number Diff line
@@ -138,6 +138,19 @@ IF ( USE_CUDA )
ENDIF()


# Enable ComputeCpp
CHECK_ENABLE_FLAG( USE_COMPUTE_CPP 0 )
IF ( USE_COMPUTE_CPP )
    LIST( APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules )
    FIND_PACKAGE( ComputeCpp REQUIRED )
    SET( USE_SYCL TRUE )
    ADD_DEFINITIONS( -DUSE_SYCL )
    INCLUDE_DIRECTORIES( ${ComputeCpp_INCLUDE_DIRS} ${OpenCL_INCLUDE_DIRS} )
    SET( CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} "${ComputeCpp_DIR}/lib" )

ENDIF()


# Include some paths
INCLUDE_DIRECTORIES( "${RAYTRACE_INSTALL_DIR}/include" )
INCLUDE_DIRECTORIES( "${RAYTRACE_SOURCE_DIR}" )
@@ -181,8 +194,13 @@ ADD_DEPENDENCIES( RayTrace copy-include )


# Add the applications
IF ( USE_SYCL )
    CMAKE_PARSE_ARGUMENTS( SDK_ADD_SAMPLE "NO_TEST" "TARGET" "SOURCES" TARGET CreateImage SOURCES SYCL/RayTraceImageSYCL.cpp )
    ADD_EXECUTABLE( CreateImage CreateImage.cpp ${SDK_ADD_SAMPLE_SOURCES} )
    ADD_SYCL_TO_TARGET( TARGET CreateImage SOURCES ${SDK_ADD_SAMPLE_SOURCES} )
ELSE()
    ADD_EXECUTABLE( CreateImage CreateImage.cpp )
TARGET_LINK_LIBRARIES( CreateImage RayTrace ${KOKKOS_LIB} ${TIMER_LIBS} ${LDFLAGS} ${LDLIBS} )
ENDIF()
TARGET_LINK_LIBRARIES( CreateImage RayTrace ${KOKKOS_LIB} ${COMPUTECPP_RUNTIME_LIBRARY} ${OpenCL_LIBRARIES} ${TIMER_LIBS} ${LDFLAGS} ${LDLIBS} )
INSTALL( TARGETS CreateImage DESTINATION ${RAYTRACE_INSTALL_DIR}/bin )
+15 −4
Original line number Diff line number Diff line
@@ -337,6 +337,9 @@ static inline std::vector<std::string> allMethods()
    methods.push_back( "Cuda" );
    methods.push_back( "Cuda-MultiGPU" );
#endif
#ifdef USE_SYCL
    methods.push_back( "SYCL" );
#endif
#ifdef USE_OPENACC
    methods.push_back( "OpenAcc" );
#endif
@@ -354,6 +357,15 @@ static inline std::vector<std::string> allMethods()
#endif
    return methods;
}
static std::string getMethodList()
{
    auto methods = allMethods();
    std::string methodList;
    for ( const auto& method : methods )
        methodList += method + ", ";
    methodList.erase( methodList.size() - 2 ); 
    return methodList;
}
static inline void erase( std::vector<std::string> &x, const std::string &v )
{
    auto it = std::find( x.begin(), x.end(), v );
@@ -363,13 +375,12 @@ static inline void erase( std::vector<std::string> &x, const std::string &v )
Options::Options() : benchmark( false ), iterations( 1 ), scale( 1.0 ) {}
Options::Options( int argc, char *argv[] ) : iterations( 1 ), scale( 1.0 )
{
    const char *err_msg =
    std::string err_msg =
        "CreateImage called with the wrong number of arguments:\n"
        "  CreateImage <args> file.dat\n"
        "Optional arguments:\n"
        "  -methods=METHODS  Comma seperated list of methods to test\n"
        "                    cpu, threads, OpenMP, Cuda, Cuda-MultiGPU, OpenAcc, Kokkos-Serial, "
        "Kokkos-Thread, Kokkos-OpenMP, Kokkos-Cuda\n"
        "  -methods=METHODS  Comma seperated list of methods to test:\n"
        "                    " + getMethodList() + "\n"
        "                    all - run all availible tests (default)\n"
        "                    parallel - run all availible parallel tests\n"
        "  -iterations=N     Number of iterations to run.\n"
+16 −0
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@
#ifdef ENABLE_CUDA
#include <cuda_runtime_api.h>
#endif
#ifdef USE_SYCL
#define ENABLE_SYCL
#endif
#include "RayTrace/common/RayTraceDefinitions.h"
#include "RayTrace/common/RayTraceImageHelper.h"
#include "RayTrace/utilities/RayUtilityMacros.h"
@@ -66,6 +69,12 @@ extern void RayTraceImageCudaLoop( int N, const RayTrace::EUV_beam_struct &euv_b
    const std::vector<ray_struct> &rays, double scale, double *image, double *I_ang,
    unsigned int &failure_code, std::vector<ray_struct> &failed_rays );
#endif
#if defined( ENABLE_SYCL )
extern void RayTraceImageSYCLLoop( int N, const RayTrace::EUV_beam_struct &euv_beam,
    const RayTrace::ray_gain_struct *gain, const RayTrace::ray_seed_struct *seed, int method,
    const std::vector<ray_struct> &rays, double scale, double *image, double *I_ang,
    unsigned int &failure_code, std::vector<ray_struct> &failed_rays );
#endif


/**********************************************************************
@@ -365,6 +374,13 @@ void RayTrace::create_image( create_image_struct *info, std::string compute_meth
            failure_code, failed_rays );
#else
        RAY_ERROR( "Cuda-MultiGPU is not availible" );
#endif
    } else if ( compute_method == "sycl" ) {
#if defined( ENABLE_SYCL )
        RayTraceImageSYCLLoop( N, std::ref( *info->euv_beam ), info->gain, info->seed, method, rays,
            scale, image, I_ang, failure_code, failed_rays );
#else
        RAY_ERROR( "SYCL is not availible" );
#endif
    } else if ( compute_method == "cpu" ) {
        RayTraceImageCPULoop( N, std::ref( *info->euv_beam ), info->gain, info->seed, method, rays,
+2 −1
Original line number Diff line number Diff line
@@ -115,8 +115,9 @@ void RayTraceImageOpenMPLoop( int N, const RayTrace::EUV_beam_struct &beam,
        if ( i1 >= 0 && i2 >= 0 ) {
            double *Iv2 = &image[beam.nv * ( i1 + i2 * beam.nx )];
            for ( int iv = 0; iv < beam.nv; iv++ ) {
                int k = (iv+i)%beam.nv;  // Offset index to reduce collisions
#pragma omp atomic
                Iv2[iv] += Iv[iv] * scale;
                Iv2[k] += Iv[k] * scale;
            }
        }
        // Copy I_out into I_ang
Loading