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 */
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);
}
cl_program
compileProgram(FILE *fplog,
+ const std::string &kernelRelativePath,
const std::string &kernelBaseFilename,
const std::string &extraDefines,
cl_context context,
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");
/*
* 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.
/*! \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
* 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,
/* 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,