Skip to content
Snippets Groups Projects
Commit c92452f2 authored by Marcel Loose's avatar Marcel Loose :sunglasses:
Browse files

Task #4520: Moved gpu_utils.h one level up (to the generic directory)....

Task #4520: Moved gpu_utils.h one level up (to the generic directory). Temporarily added method defaultFlags() and typedef of flags_type to this header. Fixed OpenCL code to (temporarily) include OpenCL-specific gpu_utils.h header.
parent a685a3ef
No related branches found
No related tags found
No related merge requests found
......@@ -47,25 +47,6 @@ namespace LOFAR
namespace Cobalt
{
// flags
typedef std::set<std::string> flags_type;
// Return the set of default flags for the nvcc compilation of a cuda kernel in Cobalt
flags_type defaultFlags()
{
flags_type flags;
using boost::format;
//flags.insert("device-debug");
flags.insert("use_fast_math"); // TODO: If this simplifies trig funcs, verify effect on the BPDelayKernel. Ideally, a Kernel specifies when to enable build flags.
// gpu-architecture and -Ipath are set by createPTX()
return flags;
};
// Performs a 'system' call of nvcc. Return the stdout of the command
// on error no stdout is created and an exception is thrown
std::string runNVCC(const std::string &cmd)
......
......@@ -31,6 +31,7 @@
#include <CoInterface/Parset.h>
#include <GPUProc/Kernels/CompileDefinitions.h>
#include <GPUProc/gpu_utils.h>
#include "gpu_incl.h"
// Collection of functions needed for runtime compilation of a kernel supplied
......@@ -40,8 +41,8 @@ namespace LOFAR
namespace Cobalt
{
// flags
typedef std::set<std::string> flags_type;
// // flags
// typedef std::set<std::string> flags_type;
// Return the set of default flags for the nvcc compilation of a cuda kernel in Cobalt
flags_type defaultFlags();
......
......@@ -20,7 +20,7 @@
#include <lofar_config.h>
#include "gpu_utils.h"
#include <GPUProc/gpu_utils.h>
#include <cstdlib>
#include <sys/types.h>
......@@ -51,6 +51,22 @@ namespace LOFAR
using namespace std;
using boost::format;
flags_type defaultFlags()
{
flags_type flags;
using boost::format;
//flags.insert("device-debug");
// TODO: If this simplifies trig funcs, verify effect on the
// BPDelayKernel. Ideally, a Kernel specifies when to enable build flags.
flags.insert("use_fast_math");
return flags;
};
namespace {
// Return the highest compute target supported by the given device
......
//# gpu_utils.h
//# Copyright (C) 2013 ASTRON (Netherlands Institute for Radio Astronomy)
//# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands
//#
//# This file is part of the LOFAR software suite.
//# The LOFAR software suite is free software: you can redistribute it and/or
//# modify it under the terms of the GNU General Public License as published
//# by the Free Software Foundation, either version 3 of the License, or
//# (at your option) any later version.
//#
//# The LOFAR software suite is distributed in the hope that it will be useful,
//# but WITHOUT ANY WARRANTY; without even the implied warranty of
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//# GNU General Public License for more details.
//#
//# You should have received a copy of the GNU General Public License along
//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
//#
//# $Id$
#ifndef LOFAR_GPUPROC_CUDA_GPU_UTILS_H
#define LOFAR_GPUPROC_CUDA_GPU_UTILS_H
#include <string>
#include <vector>
#include <CoInterface/Parset.h>
#include "gpu_wrapper.h"
#include "CudaRuntimeCompiler.h"
namespace LOFAR
{
namespace Cobalt
{
class CompileDefinitions;
/*
* If no devices are given, the program is compiled for the latest
* architecture.
*
* srcFilename cannot be an absolute path.
*/
std::string createPTX( const std::vector<gpu::Device> &devices,
const std::string &srcFilename,
flags_type &flags,
const CompileDefinitions &definitions );
/*
* Create a Module from a PTX (string).
*/
gpu::Module createModule( const gpu::Context &context,
const std::string &srcFilename,
const std::string &ptx );
}
}
#endif
//# gpu_utils.h
//#
//# Copyright (C) 2013 ASTRON (Netherlands Institute for Radio Astronomy)
//# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands
//#
......@@ -19,23 +18,46 @@
//#
//# $Id$
// \file
// Support functions for GPU device selection, context, program management.
#ifndef LOFAR_GPUPROC_CUDA_GPU_UTILS_H
#define LOFAR_GPUPROC_CUDA_GPU_UTILS_H
#ifndef LOFAR_GPU_UTILS_H
#define LOFAR_GPU_UTILS_H
#include <string>
#include <vector>
#if defined (USE_CUDA) && defined (USE_OPENCL)
# error "Either CUDA or OpenCL must be enabled, not both"
#endif
#include <CoInterface/Parset.h>
#include "gpu_wrapper.h"
// #include "CudaRuntimeCompiler.h"
#if defined (USE_CUDA)
# include "cuda/gpu_utils.h"
#elif defined (USE_OPENCL)
# include "opencl/gpu_utils.h"
#else
# error "Either CUDA or OpenCL must be enabled, not neither"
#endif
namespace LOFAR
{
namespace Cobalt
{
// flags
typedef std::set<std::string> flags_type;
// Return default flags to be used for kernel compilation. The
// implementation of this method is CUDA/OpenCL specific.
flags_type defaultFlags();
class CompileDefinitions;
/*
* If no devices are given, the program is compiled for the latest
* architecture.
*
* srcFilename cannot be an absolute path.
*/
std::string createPTX( const std::vector<gpu::Device> &devices,
const std::string &srcFilename,
flags_type &flags,
const CompileDefinitions &definitions );
/*
* Create a Module from a PTX (string).
*/
gpu::Module createModule( const gpu::Context &context,
const std::string &srcFilename,
const std::string &ptx );
}
}
#endif
......@@ -25,7 +25,7 @@
#include <Common/LofarLogger.h>
#include <Common/lofar_iomanip.h>
#include <GPUProc/gpu_utils.h>
#include <GPUProc/opencl/gpu_utils.h>
namespace LOFAR
{
......
......@@ -29,7 +29,7 @@
#include <GPUProc/global_defines.h>
#include <GPUProc/MultiDimArrayHostBuffer.h>
#include <GPUProc/gpu_utils.h>
#include <GPUProc/opencl/gpu_utils.h>
#include <UnitTest.h>
#include "Kernels/IncoherentStokesTest.h"
......
......@@ -27,7 +27,7 @@
#include <cmath>
#include <GPUProc/global_defines.h>
#include <GPUProc/gpu_utils.h>
#include <GPUProc/opencl/gpu_utils.h>
namespace LOFAR
{
......
......@@ -23,7 +23,7 @@
#include <vector>
#include <Common/LofarLogger.h>
#include <GPUProc/gpu_utils.h>
#include <GPUProc/opencl/gpu_utils.h>
using namespace LOFAR;
using namespace Cobalt;
......
......@@ -24,7 +24,7 @@
#include <Common/LofarLogger.h>
#include <GPUProc/MultiDimArrayHostBuffer.h>
#include <GPUProc/gpu_utils.h>
#include <GPUProc/opencl/gpu_utils.h>
#include <GPUProc/PerformanceCounter.h>
using namespace LOFAR;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment