mirror of git://gcc.gnu.org/git/gcc.git
plugin-nvptx.c: Don't include dlfcn.h.
* plugin/plugin-nvptx.c: Don't include dlfcn.h. (cuda_errlist): Constify. (errmsg): Move into ... (cuda_error): ... here. Make smaller. (_XSTR, _STR): Delete. (cuda_synames): Delete. (verify_device_library): Delete. (nvptx_init): Don't call it. From-SVN: r226539
This commit is contained in:
parent
1f1833cce0
commit
9ebddeb045
|
|
@ -1,3 +1,14 @@
|
||||||
|
2015-08-03 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
|
* plugin/plugin-nvptx.c: Don't include dlfcn.h.
|
||||||
|
(cuda_errlist): Constify.
|
||||||
|
(errmsg): Move into ...
|
||||||
|
(cuda_error): ... here. Make smaller.
|
||||||
|
(_XSTR, _STR): Delete.
|
||||||
|
(cuda_synames): Delete.
|
||||||
|
(verify_device_library): Delete.
|
||||||
|
(nvptx_init): Don't call it.
|
||||||
|
|
||||||
2015-07-28 Tom de Vries <tom@codesourcery.com>
|
2015-07-28 Tom de Vries <tom@codesourcery.com>
|
||||||
|
|
||||||
* testsuite/libgomp.c/uns-outer-4.c: New test.
|
* testsuite/libgomp.c/uns-outer-4.c: New test.
|
||||||
|
|
|
||||||
|
|
@ -43,16 +43,15 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <dlfcn.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define ARRAYSIZE(X) (sizeof (X) / sizeof ((X)[0]))
|
#define ARRAYSIZE(X) (sizeof (X) / sizeof ((X)[0]))
|
||||||
|
|
||||||
static struct
|
static const struct
|
||||||
{
|
{
|
||||||
CUresult r;
|
CUresult r;
|
||||||
char *m;
|
const char *m;
|
||||||
} cuda_errlist[]=
|
} cuda_errlist[]=
|
||||||
{
|
{
|
||||||
{ CUDA_ERROR_INVALID_VALUE, "invalid value" },
|
{ CUDA_ERROR_INVALID_VALUE, "invalid value" },
|
||||||
|
|
@ -109,9 +108,7 @@ static struct
|
||||||
{ CUDA_ERROR_UNKNOWN, "unknown" }
|
{ CUDA_ERROR_UNKNOWN, "unknown" }
|
||||||
};
|
};
|
||||||
|
|
||||||
static char errmsg[128];
|
static const char *
|
||||||
|
|
||||||
static char *
|
|
||||||
cuda_error (CUresult r)
|
cuda_error (CUresult r)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -119,12 +116,14 @@ cuda_error (CUresult r)
|
||||||
for (i = 0; i < ARRAYSIZE (cuda_errlist); i++)
|
for (i = 0; i < ARRAYSIZE (cuda_errlist); i++)
|
||||||
{
|
{
|
||||||
if (cuda_errlist[i].r == r)
|
if (cuda_errlist[i].r == r)
|
||||||
return &cuda_errlist[i].m[0];
|
return cuda_errlist[i].m;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf (&errmsg[0], "unknown result code: %5d", r);
|
static char errmsg[30];
|
||||||
|
|
||||||
return &errmsg[0];
|
snprintf (errmsg, sizeof (errmsg), "unknown error code: %d", r);
|
||||||
|
|
||||||
|
return errmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int instantiated_devices = 0;
|
static unsigned int instantiated_devices = 0;
|
||||||
|
|
@ -353,74 +352,6 @@ static struct ptx_event *ptx_events;
|
||||||
|
|
||||||
static struct ptx_device **ptx_devices;
|
static struct ptx_device **ptx_devices;
|
||||||
|
|
||||||
#define _XSTR(s) _STR(s)
|
|
||||||
#define _STR(s) #s
|
|
||||||
|
|
||||||
static struct _synames
|
|
||||||
{
|
|
||||||
char *n;
|
|
||||||
} cuda_symnames[] =
|
|
||||||
{
|
|
||||||
{ _XSTR (cuCtxCreate) },
|
|
||||||
{ _XSTR (cuCtxDestroy) },
|
|
||||||
{ _XSTR (cuCtxGetCurrent) },
|
|
||||||
{ _XSTR (cuCtxPushCurrent) },
|
|
||||||
{ _XSTR (cuCtxSynchronize) },
|
|
||||||
{ _XSTR (cuDeviceGet) },
|
|
||||||
{ _XSTR (cuDeviceGetAttribute) },
|
|
||||||
{ _XSTR (cuDeviceGetCount) },
|
|
||||||
{ _XSTR (cuEventCreate) },
|
|
||||||
{ _XSTR (cuEventDestroy) },
|
|
||||||
{ _XSTR (cuEventQuery) },
|
|
||||||
{ _XSTR (cuEventRecord) },
|
|
||||||
{ _XSTR (cuInit) },
|
|
||||||
{ _XSTR (cuLaunchKernel) },
|
|
||||||
{ _XSTR (cuLinkAddData) },
|
|
||||||
{ _XSTR (cuLinkComplete) },
|
|
||||||
{ _XSTR (cuLinkCreate) },
|
|
||||||
{ _XSTR (cuMemAlloc) },
|
|
||||||
{ _XSTR (cuMemAllocHost) },
|
|
||||||
{ _XSTR (cuMemcpy) },
|
|
||||||
{ _XSTR (cuMemcpyDtoH) },
|
|
||||||
{ _XSTR (cuMemcpyDtoHAsync) },
|
|
||||||
{ _XSTR (cuMemcpyHtoD) },
|
|
||||||
{ _XSTR (cuMemcpyHtoDAsync) },
|
|
||||||
{ _XSTR (cuMemFree) },
|
|
||||||
{ _XSTR (cuMemFreeHost) },
|
|
||||||
{ _XSTR (cuMemGetAddressRange) },
|
|
||||||
{ _XSTR (cuMemHostGetDevicePointer) },
|
|
||||||
{ _XSTR (cuMemHostRegister) },
|
|
||||||
{ _XSTR (cuMemHostUnregister) },
|
|
||||||
{ _XSTR (cuModuleGetFunction) },
|
|
||||||
{ _XSTR (cuModuleLoadData) },
|
|
||||||
{ _XSTR (cuStreamDestroy) },
|
|
||||||
{ _XSTR (cuStreamQuery) },
|
|
||||||
{ _XSTR (cuStreamSynchronize) },
|
|
||||||
{ _XSTR (cuStreamWaitEvent) }
|
|
||||||
};
|
|
||||||
|
|
||||||
static int
|
|
||||||
verify_device_library (void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
void *dh, *ds;
|
|
||||||
|
|
||||||
dh = dlopen ("libcuda.so", RTLD_LAZY);
|
|
||||||
if (!dh)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAYSIZE (cuda_symnames); i++)
|
|
||||||
{
|
|
||||||
ds = dlsym (dh, cuda_symnames[i].n);
|
|
||||||
if (!ds)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dlclose (dh);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline struct nvptx_thread *
|
static inline struct nvptx_thread *
|
||||||
nvptx_thread (void)
|
nvptx_thread (void)
|
||||||
{
|
{
|
||||||
|
|
@ -601,16 +532,11 @@ static bool
|
||||||
nvptx_init (void)
|
nvptx_init (void)
|
||||||
{
|
{
|
||||||
CUresult r;
|
CUresult r;
|
||||||
int rc;
|
|
||||||
int ndevs;
|
int ndevs;
|
||||||
|
|
||||||
if (instantiated_devices != 0)
|
if (instantiated_devices != 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
rc = verify_device_library ();
|
|
||||||
if (rc < 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
r = cuInit (0);
|
r = cuInit (0);
|
||||||
if (r != CUDA_SUCCESS)
|
if (r != CUDA_SUCCESS)
|
||||||
GOMP_PLUGIN_fatal ("cuInit error: %s", cuda_error (r));
|
GOMP_PLUGIN_fatal ("cuInit error: %s", cuda_error (r));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue