From: Aleksei Iupinov Date: Thu, 12 Apr 2018 14:31:43 +0000 (+0200) Subject: Make in-source OpenCL kernel path a per-module parameter X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=b4cab42aaa24d430ab5efee6f58adc665d7a9edd;p=alexxy%2Fgromacs.git Make in-source OpenCL kernel path a per-module parameter Change-Id: I19cd66b441fec6ceba74eb648bea3409b6521917 --- diff --git a/src/gromacs/gpu_utils/ocl_compiler.cpp b/src/gromacs/gpu_utils/ocl_compiler.cpp index 950c323fab..182ec20192 100644 --- a/src/gromacs/gpu_utils/ocl_compiler.cpp +++ b/src/gromacs/gpu_utils/ocl_compiler.cpp @@ -203,20 +203,22 @@ selectCompilerOptions(ocl_vendor_id_t deviceVendorId) return compilerOptions; } -/*! \brief Get the path to the main folder storing OpenCL kernels. +/*! \brief Get the path to the folder storing an OpenCL kernel. * * By default, this function constructs the full path to the OpenCL from * the known location of the binary that is running, so that we handle * both in-source and installed builds. The user can override this * behavior by defining GMX_OCL_FILE_PATH environment variable. * - * \return OS-normalized path string to the main folder storing OpenCL kernels + * \param[in] kernelRelativePath Relative path to the kernel in the source tree, + * e.g. "src/gromacs/mdlib/nbnxn_ocl" for NB kernels. + * \return OS-normalized path string to the folder storing OpenCL kernel * * \throws std::bad_alloc if out of memory. * FileIOError if GMX_OCL_FILE_PATH does not specify a readable path */ static std::string -getKernelRootPath() +getKernelRootPath(const std::string &kernelRelativePath) { std::string kernelRootPath; /* Use GMX_OCL_FILE_PATH if the user has defined it */ @@ -228,7 +230,7 @@ getKernelRootPath() root path from the path to the binary that is running. */ InstallationPrefixInfo info = getProgramContext().installationPrefix(); std::string dataPathSuffix = (info.bSourceLayout ? - "src/gromacs/mdlib/nbnxn_ocl" : + kernelRelativePath : OCL_INSTALL_DIR); kernelRootPath = Path::join(info.path, dataPathSuffix); } @@ -410,6 +412,7 @@ makePreprocessorOptions(const std::string &kernelRootPath, cl_program compileProgram(FILE *fplog, + const std::string &kernelRelativePath, const std::string &kernelBaseFilename, const std::string &extraDefines, cl_context context, @@ -417,7 +420,7 @@ compileProgram(FILE *fplog, ocl_vendor_id_t deviceVendorId) { cl_int cl_error; - std::string kernelRootPath = getKernelRootPath(); + std::string kernelRootPath = getKernelRootPath(kernelRelativePath); GMX_RELEASE_ASSERT(fplog != nullptr, "Need a valid log file for building OpenCL programs"); diff --git a/src/gromacs/gpu_utils/ocl_compiler.h b/src/gromacs/gpu_utils/ocl_compiler.h index 33e64941ce..c25e4d6c27 100644 --- a/src/gromacs/gpu_utils/ocl_compiler.h +++ b/src/gromacs/gpu_utils/ocl_compiler.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by + * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -56,6 +56,8 @@ namespace ocl /*! \brief Compile the specified kernel for the context and device. * * \param[out] fplog Open file pointer for log output + * \param[in] kernelRelativePath Relative path to the kernel in the source tree, + * e.g. "src/gromacs/mdlib/nbnxn_ocl" for NB kernels. * \param[in] kernelBaseFilename The name of the kernel source file to compile, e.g. "nbnxn_ocl_kernels.cl" * \param[in] extraDefines Preprocessor defines required by the calling code, e.g. for configuring the kernels * \param[in] context OpenCL context on the device to compile for @@ -74,6 +76,7 @@ namespace ocl * InternalError if an OpenCL API error prevents returning a valid compiled program. */ cl_program compileProgram(FILE *fplog, + const std::string &kernelRelativePath, const std::string &kernelBaseFilename, const std::string &extraDefines, cl_context context, diff --git a/src/gromacs/mdlib/nbnxn_ocl/nbnxn_ocl_jit_support.cpp b/src/gromacs/mdlib/nbnxn_ocl/nbnxn_ocl_jit_support.cpp index 61eb5f0e77..874869a2f3 100644 --- a/src/gromacs/mdlib/nbnxn_ocl/nbnxn_ocl_jit_support.cpp +++ b/src/gromacs/mdlib/nbnxn_ocl/nbnxn_ocl_jit_support.cpp @@ -218,6 +218,7 @@ nbnxn_gpu_compile_kernels(gmx_nbnxn_ocl_t *nb) /* TODO when we have a proper MPI-aware logging module, the log output here should be written there */ program = gmx::ocl::compileProgram(stderr, + "src/gromacs/mdlib/nbnxn_ocl", "nbnxn_ocl_kernels.cl", extraDefines, nb->dev_rundata->context,