~ubuntu-branches/ubuntu/vivid/mpich/vivid-proposed

« back to all changes in this revision

Viewing changes to src/pm/hydra/tools/topo/hwloc/hwloc/tests/cuda.c

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2014-04-01 20:24:20 UTC
  • mfrom: (5.2.4 sid)
  • Revision ID: package-import@ubuntu.com-20140401202420-t5ey1ia2klt5dkq3
Tags: 3.1-4
* [c3e3398] Disable test_primitives, which is unreliable on some platforms.
            (Closes: #743047)
* [265a699] Add minimal autotest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright © 2010 inria.  All rights reserved.
 
2
 * Copyright © 2010-2012 Inria.  All rights reserved.
3
3
 * Copyright © 2011 Cisco Systems, Inc.  All rights reserved.
4
4
 * See COPYING in top-level directory.
5
5
 */
34
34
  printf("cuDeviceGetCount found %d devices\n", count);
35
35
 
36
36
  hwloc_topology_init(&topology);
 
37
  hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_IO_DEVICES);
37
38
  hwloc_topology_load(topology);
38
39
 
39
40
  for(i=0; i<count; i++) {
40
41
    hwloc_bitmap_t set;
 
42
    hwloc_obj_t osdev, osdev2, ancestor;
 
43
    const char *value;
41
44
 
42
45
    cres = cuDeviceGet(&device, i);
43
46
    if (cres != CUDA_SUCCESS) {
45
48
      continue;
46
49
    }
47
50
 
 
51
    osdev = hwloc_cuda_get_device_osdev(topology, device);
 
52
    assert(osdev);
 
53
    osdev2 = hwloc_cuda_get_device_osdev_by_index(topology, i);
 
54
    assert(osdev == osdev2);
 
55
 
 
56
    ancestor = hwloc_get_non_io_ancestor_obj(topology, osdev);
 
57
 
 
58
    printf("found OSDev %s\n", osdev->name);
 
59
    err = strncmp(osdev->name, "cuda", 4);
 
60
    assert(!err);
 
61
    assert(atoi(osdev->name+4) == (int) i);
 
62
 
 
63
    value = hwloc_obj_get_info_by_name(osdev, "Backend");
 
64
    err = strcmp(value, "CUDA");
 
65
    assert(!err);
 
66
 
 
67
    assert(osdev->attr->osdev.type == HWLOC_OBJ_OSDEV_COPROC);
 
68
 
 
69
    value = hwloc_obj_get_info_by_name(osdev, "CoProcType");
 
70
    err = strcmp(value, "CUDA");
 
71
    assert(!err);
 
72
    
 
73
    value = hwloc_obj_get_info_by_name(osdev, "GPUModel");
 
74
    printf("found OSDev model %s\n", value);
 
75
 
48
76
    set = hwloc_bitmap_alloc();
49
77
    err = hwloc_cuda_get_device_cpuset(topology, device, set);
50
78
    if (err < 0) {
53
81
      char *cpuset_string = NULL;
54
82
      hwloc_bitmap_asprintf(&cpuset_string, set);
55
83
      printf("got cpuset %s for device %d\n", cpuset_string, i);
 
84
      assert(hwloc_bitmap_isequal(set, ancestor->cpuset));
56
85
      free(cpuset_string);
57
86
    }
58
87
    hwloc_bitmap_free(set);