imate
C++/CUDA Reference
device_properties.cu
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: Copyright 2021, Siavash Ameli <sameli@berkeley.edu>
3
* SPDX-License-Identifier: BSD-3-Clause
4
* SPDX-FileType: SOURCE
5
*
6
* This program is free software: you can redistribute it and/or modify it
7
* under the terms of the license found in the LICENSE.txt file in the root
8
* directory of this source tree.
9
*/
10
11
12
// =======
13
// Headers
14
// =======
15
16
#include "
./device_properties.h
"
17
#include <cstdlib>
// NULL
18
19
20
// ===========
21
// Constructor
22
// ===========
23
26
27
DeviceProperties::DeviceProperties
():
28
num_devices(0),
29
num_multiprocessors(NULL),
30
num_threads_per_multiprocessor(NULL)
31
{
32
}
33
34
35
// ==========
36
// Destructor
37
// ==========
38
41
42
DeviceProperties::~DeviceProperties
()
43
{
44
this->
deallocate_members
();
45
}
46
47
48
// ==================
49
// deallocate members
50
// ==================
51
54
55
void
DeviceProperties::deallocate_members
()
56
{
57
if
(this->
num_multiprocessors
!= NULL)
58
{
59
delete
[] this->
num_multiprocessors
;
60
this->
num_multiprocessors
= NULL;
61
}
62
63
if
(this->
num_threads_per_multiprocessor
!= NULL)
64
{
65
delete
[] this->
num_threads_per_multiprocessor
;
66
this->
num_threads_per_multiprocessor
= NULL;
67
}
68
}
69
70
71
// ===============
72
// set num devices
73
// ===============
74
80
81
void
DeviceProperties::set_num_devices
(
int
num_devices_)
82
{
83
this->
num_devices
= num_devices_;
84
85
// Deallocate members in case they were allocated before
86
this->
deallocate_members
();
87
88
// Allocate members
89
this->
num_multiprocessors
=
new
int
[this->
num_devices
];
90
this->
num_threads_per_multiprocessor
=
new
int
[this->
num_devices
];
91
}
device_properties.h
DeviceProperties::num_devices
int num_devices
Definition:
device_properties.h:32
DeviceProperties::num_multiprocessors
int * num_multiprocessors
Definition:
device_properties.h:33
DeviceProperties::deallocate_members
void deallocate_members()
Deallocates the member data.
Definition:
device_properties.cu:55
DeviceProperties::~DeviceProperties
~DeviceProperties()
Destructor.
Definition:
device_properties.cu:42
DeviceProperties::DeviceProperties
DeviceProperties()
Constructor.
Definition:
device_properties.cu:27
DeviceProperties::num_threads_per_multiprocessor
int * num_threads_per_multiprocessor
Definition:
device_properties.h:34
DeviceProperties::set_num_devices
void set_num_devices(int num_devices_)
Sets the number of devices and allocates memory for member data with the size of devices.
Definition:
device_properties.cu:81
imate
_cuda_utilities
device_properties.cu
Generated on Mon Jan 22 2024 00:04:57 for imate by
1.9.1