示例#1
0
int
main (int argc, char **argv)
{
    void *d;
    acc_device_t devtype = acc_device_host;

#if ACC_DEVICE_TYPE_nvidia
    devtype = acc_device_nvidia;

    if (acc_get_num_devices (acc_device_nvidia) == 0)
        return 0;
#endif

    acc_init (devtype);

    d = acc_malloc (0);
    if (d != NULL)
        abort ();

    acc_free (0);

    acc_shutdown (devtype);

    acc_set_device_type (devtype);

    d = acc_malloc (0);
    if (d != NULL)
        abort ();

    acc_shutdown (devtype);

    acc_init (devtype);

    d = acc_malloc (1024);
    if (d == NULL)
        abort ();

    acc_free (d);

    acc_shutdown (devtype);

    acc_set_device_type (devtype);

    d = acc_malloc (1024);
    if (d == NULL)
        abort ();

    acc_free (d);

    acc_shutdown (devtype);

    return 0;
}
示例#2
0
attribute_hidden void
select_acc_device (int device_type)
{
  goacc_lazy_initialize ();

  if (device_type == GOMP_DEVICE_HOST_FALLBACK)
    return;

  if (device_type == acc_device_none)
    device_type = acc_device_host;

  if (device_type >= 0)
    {
      /* NOTE: this will go badly if the surrounding data environment is set up
         to use a different device type.  We'll just have to trust that users
	 know what they're doing...  */
      acc_set_device_type (device_type);
    }
}