Gromacs  2019-beta2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
gpu_utils_ocl.cpp File Reference
#include "gmxpre.h"
#include "config.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include "gromacs/gpu_utils/gpu_utils.h"
#include "gromacs/gpu_utils/ocl_compiler.h"
#include "gromacs/gpu_utils/oclutils.h"
#include "gromacs/hardware/hw_info.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
+ Include dependency graph for gpu_utils_ocl.cpp:

Description

Define functions for detection and initialization for OpenCL devices.

Author
Anca Hamuraru anca@.nosp@m.stre.nosp@m.amcom.nosp@m.puti.nosp@m.ng.eu
Dimitrios Karkoulis dimit.nosp@m.ris..nosp@m.karko.nosp@m.ulis.nosp@m.@gmai.nosp@m.l.co.nosp@m.m
Teemu Virolainen teemu.nosp@m.@str.nosp@m.eamco.nosp@m.mput.nosp@m.ing.e.nosp@m.u

Functions

static bool runningOnCompatibleOSForAmd ()
 Return true if executing on compatible OS for AMD OpenCL. More...
 
static int is_gmx_supported_gpu_id (gmx_device_info_t *ocl_gpu_device)
 Returns true if the gpu characterized by the device properties is supported by the native gpu acceleration. More...
 
static ocl_vendor_id_t get_vendor_id (char *vendor_name)
 Returns an ocl_vendor_id_t value corresponding to the input OpenCL vendor name. More...
 
bool canDetectGpus (std::string *errorMessage)
 This function is documented in the header file. More...
 
void findGpus (gmx_gpu_info_t *gpu_info)
 This function is documented in the header file. More...
 
void get_gpu_device_info_string (char *s, const gmx_gpu_info_t &gpu_info, int index)
 This function is documented in the header file. More...
 
bool areAllGpuDevicesFromAmd (const gmx_gpu_info_t &gpuInfo)
 Returns whether all compatible OpenCL devices are from AMD. More...
 
void init_gpu (const gmx_device_info_t *deviceInfo)
 This function is documented in the header file. More...
 
gmx_device_info_tgetDeviceInfo (const gmx_gpu_info_t &gpu_info, int deviceId)
 This function is documented in the header file. More...
 
size_t sizeof_gpu_dev_info ()
 This function is documented in the header file. More...
 
void gpu_set_host_malloc_and_free (bool bUseGpuKernels, gmx_host_alloc_t **nb_alloc, gmx_host_free_t **nb_free)
 Set page-locked memory allocation functions used by the GPU host. More...
 
int gpu_info_get_stat (const gmx_gpu_info_t &info, int index)
 Get status of device with specified index.
 

Function Documentation

bool areAllGpuDevicesFromAmd ( const gmx_gpu_info_t &  gpuInfo)

Returns whether all compatible OpenCL devices are from AMD.

This is currently the most useful and best tested platform for supported OpenCL devices, so some modules may need to check what degree of support they should offer.

Todo:
An enumeration visible in the hardware module would make such checks more configurable, if we discover other needs in future.
Returns
whether all detected compatible devices have AMD for the vendor.
bool canDetectGpus ( std::string *  errorMessage)

This function is documented in the header file.

Return whether GPUs can be detected.

void findGpus ( gmx_gpu_info_t *  gpu_info)

This function is documented in the header file.

Find all GPUs in the system.

void get_gpu_device_info_string ( char *  s,
const gmx_gpu_info_t &  gpu_info,
int  index 
)

This function is documented in the header file.

Formats and returns a device information string for a given GPU.

static ocl_vendor_id_t get_vendor_id ( char *  vendor_name)
static

Returns an ocl_vendor_id_t value corresponding to the input OpenCL vendor name.

Parameters
[in]vendor_nameString with OpenCL vendor name.
Returns
ocl_vendor_id_t value for the input vendor_name
gmx_device_info_t* getDeviceInfo ( const gmx_gpu_info_t &  gpu_info,
int  deviceId 
)

This function is documented in the header file.

Return a pointer to the device info for deviceId.

void gpu_set_host_malloc_and_free ( bool  bUseGpuKernels,
gmx_host_alloc_t **  nb_alloc,
gmx_host_free_t **  nb_free 
)

Set page-locked memory allocation functions used by the GPU host.

Set page-locked memory allocation functions used by the GPU host.

Since GPU support is not configured, there is no host memory to allocate.

void init_gpu ( const gmx_device_info_t deviceInfo)

This function is documented in the header file.

Initializes the GPU described by deviceInfo.

static int is_gmx_supported_gpu_id ( gmx_device_info_t ocl_gpu_device)
static

Returns true if the gpu characterized by the device properties is supported by the native gpu acceleration.

Returns
true if the GPU properties passed indicate a compatible GPU, otherwise false.
static bool runningOnCompatibleOSForAmd ( )
static

Return true if executing on compatible OS for AMD OpenCL.

This is assumed to be true for OS X version of at least 10.10.4 and all other OS flavors.

Uses the BSD sysctl() interfaces to extract the kernel version.

Returns
true if version is 14.4 or later (= OS X version 10.10.4), or OS is not Darwin.
size_t sizeof_gpu_dev_info ( )

This function is documented in the header file.

Returns the size of the gpu_dev_info struct.