pax_global_header 0000666 0000000 0000000 00000000064 14177511724 0014523 g ustar 00root root 0000000 0000000 52 comment=4040c23c0841b9b1fbf9397f842a9e9cec7356b5
thinkfan-1.3.1/ 0000775 0000000 0000000 00000000000 14177511724 0013327 5 ustar 00root root 0000000 0000000 thinkfan-1.3.1/.github/ 0000775 0000000 0000000 00000000000 14177511724 0014667 5 ustar 00root root 0000000 0000000 thinkfan-1.3.1/.github/workflows/ 0000775 0000000 0000000 00000000000 14177511724 0016724 5 ustar 00root root 0000000 0000000 thinkfan-1.3.1/.github/workflows/ccpp.yml 0000664 0000000 0000000 00000001026 14177511724 0020373 0 ustar 00root root 0000000 0000000 name: C/C++ CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build-ubuntu:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04]
steps:
- uses: actions/checkout@v2
- name: install-deps
run: sudo apt install libyaml-cpp-dev libatasmart-dev cmake
- name: build
run: |
mkdir build
cmake -B build
cmake --build build
- name: install
run: sudo cmake --install ${{ github.workspace }}/build
thinkfan-1.3.1/CMakeLists.txt 0000664 0000000 0000000 00000012703 14177511724 0016072 0 ustar 00root root 0000000 0000000 project(thinkfan)
include(GNUInstallDirs)
set(THINKFAN_VERSION 1.3.1)
cmake_minimum_required(VERSION 3.0)
# Generate absolute paths or something
cmake_policy(SET CMP0015 NEW)
find_package(PkgConfig)
find_package(Threads)
pkg_check_modules(SYSTEMD "systemd")
pkg_check_modules(OPENRC "openrc")
pkg_check_modules(YAML_CPP "yaml-cpp")
if(YAML_CPP_FOUND AND YAML_CPP_VERSION VERSION_LESS "0.5.3")
message(WARNING "yaml-cpp version ${YAML_CPP_VERSION} is very old, buggy and lacks some features. Thinkfan will not always be able to point out the location of errors in the YAML config.")
add_definitions(-DHAVE_OLD_YAMLCPP)
endif()
pkg_check_modules(ATASMART "libatasmart")
if(SYSTEMD_FOUND)
set(PID_FILE "/run/thinkfan.pid")
else()
set(PID_FILE "/var/run/thinkfan.pid")
endif()
#
# Defaults to OFF because libatasmart seems to be horribly inefficient
#
option(USE_ATASMART "Enable reading temperatures from HDDs via S.M.A.R.T" OFF)
#
# Defaults to ON because it seems reasonably fast. The libnvidia-ml.so is
# loaded at runtime, so we don't add a compile-time dependency on the
# proprietary nVidia driver.
#
option(USE_NVML "Get temperatures directly from nVidia GPUs via their proprietary NVML API" ON)
#
# The shiny new YAML config parser. Depends on yaml-cpp.
#
option(USE_YAML "Enable the new YAML-based config format" ON)
option(DISABLE_BUGGER "Disable bug detection, i.e. dont't catch segfaults and unhandled exceptions" OFF)
option(DISABLE_SYSLOG "Disable logging to syslog, always log to stdout" OFF)
option(DISABLE_EXCEPTION_CATCHING "Terminate with SIGABRT on all exceptions, causing a core dump on every error" OFF)
set(SRC_FILES src/thinkfan.cpp src/config.cpp src/fans.cpp src/sensors.cpp
src/message.cpp src/parser.cpp src/error.cpp)
if(USE_YAML)
if(NOT YAML_CPP_FOUND)
message(FATAL_ERROR "USE_YAML enabled but yaml-cpp not found. Please install yaml-cpp[-devel]!")
endif()
set(SRC_FILES ${SRC_FILES} src/yamlconfig.cpp)
endif(USE_YAML)
#
# Set default build type
#
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
add_compile_options(-Wall -std=c++1y)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3 -DDEBUG")
add_executable(thinkfan ${SRC_FILES})
if (PID_FILE)
target_compile_definitions(thinkfan PRIVATE -DPID_FILE=\"${PID_FILE}\")
endif()
target_compile_definitions(thinkfan PRIVATE -DVERSION="${THINKFAN_VERSION}")
# std::condition_variable::wait_for doesn't block if not explicitly linked against libpthread
# https://stackoverflow.com/questions/41394670/c-condition-variable-wait-for-returns-instantly
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58929
target_link_libraries(thinkfan PRIVATE ${CMAKE_THREAD_LIBS_INIT})
if(USE_ATASMART)
if(NOT ATASMART_FOUND)
message(FATAL_ERROR "USE_ATASMART enabled but libatasmart not found. Please install libatasmart[-devel]!")
else()
target_compile_definitions(thinkfan PRIVATE -DUSE_ATASMART)
target_link_libraries(thinkfan PRIVATE atasmart)
endif()
endif(USE_ATASMART)
if(USE_NVML)
target_include_directories(thinkfan PRIVATE "include")
target_compile_definitions(thinkfan PRIVATE -DUSE_NVML)
target_link_libraries(thinkfan PRIVATE dl)
endif(USE_NVML)
if(USE_YAML)
target_compile_definitions(thinkfan PRIVATE -DUSE_YAML)
target_include_directories(thinkfan PRIVATE ${YAML_CPP_INCLUDE_DIRS})
target_link_libraries(thinkfan PRIVATE ${YAML_CPP_LIBRARIES})
endif(USE_YAML)
if(SYSTEMD_FOUND)
target_compile_definitions(thinkfan PRIVATE -DHAVE_SYSTEMD)
endif()
if(DISABLE_BUGGER)
target_compile_definitions(thinkfan PRIVATE -DDISABLE_BUGGER)
endif(DISABLE_BUGGER)
if(DISABLE_SYSLOG)
target_compile_definitions(thinkfan PRIVATE -DDISABLE_SYSLOG)
endif(DISABLE_SYSLOG)
if(DISABLE_EXCEPTION_CATCHING)
target_compile_definitions(thinkfan PRIVATE -DDISABLE_EXCEPTION_CATCHING)
endif(DISABLE_EXCEPTION_CATCHING)
configure_file(src/thinkfan.1.cmake thinkfan.1)
configure_file(src/thinkfan.conf.5.cmake thinkfan.conf.5)
configure_file(src/thinkfan.conf.legacy.5.cmake thinkfan.conf.legacy.5)
install(TARGETS thinkfan DESTINATION "${CMAKE_INSTALL_SBINDIR}")
install(FILES COPYING README.md examples/thinkfan.yaml DESTINATION "${CMAKE_INSTALL_DOCDIR}")
install(FILES ${CMAKE_BINARY_DIR}/thinkfan.1 DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
install(FILES ${CMAKE_BINARY_DIR}/thinkfan.conf.5 DESTINATION "${CMAKE_INSTALL_MANDIR}/man5")
install(FILES ${CMAKE_BINARY_DIR}/thinkfan.conf.legacy.5 DESTINATION "${CMAKE_INSTALL_MANDIR}/man5")
if(SYSTEMD_FOUND)
configure_file(rcscripts/systemd/thinkfan.service.cmake
rcscripts/systemd/thinkfan.service)
install(FILES
rcscripts/systemd/thinkfan-sleep.service
rcscripts/systemd/thinkfan-wakeup.service
"${CMAKE_BINARY_DIR}/rcscripts/systemd/thinkfan.service"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/systemd/system")
if(NOT EXISTS "/etc/systemd/system/thinkfan.service.d/override.conf")
install(FILES
rcscripts/systemd/override.conf
DESTINATION "/etc/systemd/system/thinkfan.service.d")
else()
install(FILES
rcscripts/systemd/override.conf
DESTINATION "/etc/systemd/system/thinkfan.service.d"
RENAME "default.conf")
endif()
endif(SYSTEMD_FOUND)
if(OPENRC_FOUND)
configure_file(rcscripts/openrc/thinkfan.cmake
rcscripts/openrc/thinkfan)
install(FILES
"${CMAKE_BINARY_DIR}/rcscripts/openrc/thinkfan"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION "/etc/init.d")
endif(OPENRC_FOUND)
thinkfan-1.3.1/COPYING 0000664 0000000 0000000 00000104513 14177511724 0014366 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
thinkfan-1.3.1/README.md 0000664 0000000 0000000 00000006652 14177511724 0014617 0 ustar 00root root 0000000 0000000 # thinkfan [](https://lgtm.com/projects/g/vmatare/thinkfan/alerts/)[](https://lgtm.com/projects/g/vmatare/thinkfan/context:cpp)
Thinkfan is a simple, lightweight fan control program.
# WARNING
There's only very basic sanity checking on the configuration (semantic
plausibility). You can set the temperature limits as insane as you like.
Any change to fan behaviour that results in higher temperatures in some parts
of the system will shorten your system's lifetime and/or cause weird hardware
bugs that'll make you pull out your hair.
**No warranties whatsoever**
If this program steals your car, kills your horse, smokes your dope or pees
on your carpet... too bad, you're on your own.
# Building and installing
To compile thinkfan, you will need to have the following things installed:
- A recent C++ compiler (GCC >= 4.8 or clang)
- pkgconfig or an equivalent (pkgconf or pkg-config)
- cmake (and optionally a cmake GUI if you want to configure interactively)
- optional: libyaml-cpp for YAML support (the -dev or -devel package)
1. In the thinkfan main directory, do
```bash
mkdir build && cd build
```
2. Then configure your build, either interactively:
```bash
ccmake ..
```
Or set your build options from the command line. E.g. to configure a build
with full debugging support:
```bash
cmake -D CMAKE_BUILD_TYPE:STRING=Debug ..
```
`CMAKE_BUILD_TYPE:STRING` can also be `Release`, which produces a fully
optimized binary, or `RelWithDebInfo`, which is also optimized but can
still be debugged with gdb.
Other options are:
`USE_NVML:BOOL` (default: `ON`)
Allows thinkfan to read GPU temperatures from the proprietary nVidia
driver. The interface library is loaded dynamically, so it does not
need to be installed when compiling.
`USE_ATASMART:BOOL` (default: `OFF`)
Enable libatasmart to read temperatures directly from hard disks. Use
this only when you really need it, since libatasmart is unreasonably
CPU-intensive.
`USE_YAML:BOOL` (default: `ON`)
Support config file in the new, more flexible YAML format. The old
config format will be deprecated after the thinkfan 1.0 release. New
features will be supported in YAML configs only. See
examples/thinkfan.conf.yaml. Requires libyaml-cpp.
3. To compile simply run:
```bash
make
```
4. If you did not change `CMAKE_INSTALL_PREFIX`, thinkfan will be installed
under `/usr/local` by doing:
```bash
sudo make install
```
CMake will detect whether you use OpenRC or systemd and install some
appropriate service files. With systemd, you can edit the commandline
arguments of the thinkfan service with `systemctl edit thinkfan`.
With OpenRC, we install only a plain initscript (edit `/etc/init.d/thinkfan`
to change options).
# Documentation
- Run `thinkfan -h`
- Manpages: `thinkfan(1)`, `thinkfan.conf(5)`
- Example configs: https://github.com/vmatare/thinkfan/tree/master/examples
- Linux kernel hwmon doc: https://www.kernel.org/doc/html/latest/hwmon/sysfs-interface.html
- Linux kernel thinkpad_acpi doc: https://www.kernel.org/doc/html/latest/admin-guide/laptops/thinkpad-acpi.html
- If all fails: https://github.com/vmatare/thinkfan/issues
thinkfan-1.3.1/examples/ 0000775 0000000 0000000 00000000000 14177511724 0015145 5 ustar 00root root 0000000 0000000 thinkfan-1.3.1/examples/thinkfan.yaml 0000664 0000000 0000000 00000015530 14177511724 0017637 0 ustar 00root root 0000000 0000000 ##############################################################################
# thinkfan Example Config File
# ============================
#
# Please read the config manpage thinkfan.conf(5) before playing around with
# this.
#
# This is NOT a working config file that can just be copied. It is only meant
# to give a rough idea what can be done. In particular, don't copy & paste the
# fan speed config! Think about what you're doing.
#
# If you don't know what temperatures are right for your system, you should
# not be using thinkfan!
##############################################################################
##############################################################################
# Sensor Drivers and Temperature Inputs
# =====================================
#
# ATTENTION: The order in which sensors are specified here is significant when
# specifying the fan speeds further below!
#
# There are multiple ways in which a temperature input can be specified. An
# example for each is given below.
#
# The "correction:" and "optional:" keywords may be specified on any type of
# sensor.
sensors:
# hwmon: Full path to a temperature file (single sensor).
# =======================================================
# Disadvantage is that the index in "hwmon0" depends on the load order of
# the driver modules, which may change across bootups on some systems.
- hwmon: /sys/class/hwmon/hwmon0/temp1_input
# hwmon: Path to a complete driver folder
# =======================================
# Individual sensors need to be picked out with the "indices:" keyword.
# This can be used with a stable path that does not depend on driver load
# order. However certain drivers may not appear under such a stable path.
- hwmon: /sys/devices/pci0000:00/0000:00:03.1/0000:27:00.0/hwmon
indices: [1, 2, 5, 6] # adds 4 temperature sensors
correction: [0, 0, 0, -5] # add -5 °C to temp6_input
# hwmon: Base path with name-based search
# =======================================
# Thinkfan will search under the given path for a hwmon driver that has a
# file called "name" which contains the given name. This method should work
# with all hwmon drivers and is robust against driver load order.
- hwmon: /sys/class/hwmon
name: k10temp
indices: [1]
# Sensors can also be optional, e.g. in case of removable hardware
- hwmon: /sys/class/block/sdc/device/hwmon
indices: [1]
optional: true # don't exit if the sensor can't be read
# atasmart: Read the temperature from a hard disk via S.M.A.R.T
# =============================================================
# Note that this is unreasonably CPU-intensive. Since Linux 5.6, the kernel
# can report the temperatures of hard disks via the hwmon interface (see the
# example above), which should be preferred if available.
#
# This is only available if thinkfan was compiled with USE_ATASMART enabled.
- atasmart: /dev/sda
# tpacpi: Legacy interface to the thinkpad_acpi driver
# ====================================================
# Particularly on older Thinkpad laptops, this interface may give access to
# 8-16 temperature sensors, but it may be hard to tell where/what exactly
# they measure.
# Some documentation for older models may be found at the thinkpad wiki:
# https://www.thinkwiki.org/wiki/Thermal_Sensors
#
# Note that the hwmon interface is to be preferred nowadays.
- tpacpi: /proc/acpi/ibm/thermal
# Some of the temperature entries in /proc/acpi/ibm/thermal may be
# irrelevant or unused, so individual ones can be selected:
indices: [1, 2, 3, 4]
# nvml: The proprietary nVidia driver
# ===================================
# Temperatures can be read directly from nVidia GPUs that run with the
# proprietary driver. The "nvml:" entry must specify the PCI bus ID of the
# GPU (can be found with lspci)
#
# Note that this does not work with the open-source "nouveau" driver. Open
# source drivers should support the hwmon interface instead (see above).
- nvml: 27:00.0
##############################################################################
##############################################################################
# Fan Drivers
# ===========
#
# Currently, thinkfan supports only one fan, but support for multiple fans is
# in development and will be released soon. For the time being, the examples
# given below are mutually exclusive.
#
fans:
# hwmon: Full path to a PWM file
# ==============================
# Also subject to the potential problem with driver load order (see above)
- hwmon: /sys/class/hwmon/hwmon0/pwm1
# hwmon: Path to a complete driver folder
# =======================================
- hwmon: /sys/class/graphics/fb0/device/hwmon
indices: [1] # Use pwm1
# hwmon: Base path with name-based search
# =======================================
- hwmon: /sys/class/hwmon
name: amdgpu
indices: [1]
# tpacpi: Thinkpad-specific fan interface
# =======================================
# Currently, this is the only way to use disengaged and automatic mode on
# thinkpads.
- tpacpi: /proc/acpi/ibm/fan
##############################################################################
##############################################################################
# Fan Speeds (simple mode)
# ========================
#
# In simple mode, each entry is a [FANSPEED, LOWER_LIMIT, UPPER_LIMIT] tuple.
# This is a quick way to configure a small system like a laptop, where the
# temperature ratings for all monitored devices are similar. Only the highest
# temperature found across all sensors will be compared against these limits.
# All other temperatures are ignored.
#
# Correction values on individual sensors (see above) may be used to equalize
# small discrepancies in temperature ratings.
#
# The FANSPEED values in this example are valid for the thinkpad_acpi fan
# driver only (see above)
#
levels:
- [0, 0, 50]
- ["level auto", 45, 75]
- ["level disengaged", 70, 255]
##############################################################################
##############################################################################
# Fan Speeds (detailed mode)
# ==========================
#
# It is generally advisable to configure the temperature limits for each
# sensor individually.
#
# The speed values used here range from 0 to 255, which is valid for the PWM
# control files used by hwmon-based drivers.
#
# The temperatures specified in upper_limit and lower_limit apply to the
# sensors in the same order in which they were specified in the "sensors:"
# section above, and their length must match the total number of sensors that
# have been configured.
#
levels:
- speed: 0
upper_limit: [50, 50, 50]
- speed: 100
lower_limit: [45, 45, 45]
upper_limit: [65, 65, 65]
- speed: 255
lower_limit: [60, 60, 60]
##############################################################################
thinkfan-1.3.1/include/ 0000775 0000000 0000000 00000000000 14177511724 0014752 5 ustar 00root root 0000000 0000000 thinkfan-1.3.1/include/nvidia/ 0000775 0000000 0000000 00000000000 14177511724 0016224 5 ustar 00root root 0000000 0000000 thinkfan-1.3.1/include/nvidia/gdk/ 0000775 0000000 0000000 00000000000 14177511724 0016771 5 ustar 00root root 0000000 0000000 thinkfan-1.3.1/include/nvidia/gdk/nvml.h 0000664 0000000 0000000 00000554013 14177511724 0020126 0 ustar 00root root 0000000 0000000 /*
* Copyright 1993-2015 NVIDIA Corporation. All rights reserved.
*
* NOTICE TO USER:
*
* This source code is subject to NVIDIA ownership rights under U.S. and
* international Copyright laws. Users and possessors of this source code
* are hereby granted a nonexclusive, royalty-free license to use this code
* in individual and commercial software.
*
* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
* OR PERFORMANCE OF THIS SOURCE CODE.
*
* U.S. Government End Users. This source code is a "commercial item" as
* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
* "commercial computer software" and "commercial computer software
* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
* and is provided to the U.S. Government only as a commercial end item.
* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
* source code with only those rights set forth herein.
*
* Any use of this source code in individual and commercial software must
* include, in the user documentation and internal comments to the code,
* the above Disclaimer and U.S. Government End Users Notice.
*/
/*
NVML API Reference
The NVIDIA Management Library (NVML) is a C-based programmatic interface for monitoring and
managing various states within NVIDIA Tesla &tm; GPUs. It is intended to be a platform for building
3rd party applications, and is also the underlying library for the NVIDIA-supported nvidia-smi
tool. NVML is thread-safe so it is safe to make simultaneous NVML calls from multiple threads.
API Documentation
Supported platforms:
- Windows: Windows Server 2008 R2 64bit, Windows Server 2012 R2 64bit, Windows 7 64bit, Windows 8 64bit
- Linux: 32-bit and 64-bit
- Hypervisors: Windows Server 2008R2/2012 Hyper-V 64bit, Citrix XenServer 6.2 SP1+, VMware ESX 5.1/5.5
Supported products:
- Full Support
- All Tesla products, starting with the Fermi architecture
- All Quadro products, starting with the Fermi architecture
- All GRID products, starting with the Kepler architecture
- Selected GeForce Titan products
- Limited Support
- All Geforce products, starting with the Fermi architecture
The NVML library can be found at \%ProgramW6432\%\\"NVIDIA Corporation"\\NVSMI\\ on Windows. It is
not be added to the system path by default. To dynamically link to NVML, add this path to the PATH
environmental variable. To dynamically load NVML, call LoadLibrary with this path.
On Linux the NVML library will be found on the standard library path. For 64 bit Linux, both the 32 bit
and 64 bit NVML libraries will be installed.
Online documentation for this library is available at http://docs.nvidia.com/deploy/nvml-api/index.html
*/
#ifndef __nvml_nvml_h__
#define __nvml_nvml_h__
#ifdef __cplusplus
extern "C" {
#endif
/*
* On Windows, set up methods for DLL export
* define NVML_STATIC_IMPORT when using nvml_loader library
*/
#if defined _WINDOWS
#if !defined NVML_STATIC_IMPORT
#if defined NVML_LIB_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif
#else
#define DECLDIR
#endif
#else
#define DECLDIR
#endif
/**
* NVML API versioning support
*/
#define NVML_API_VERSION 7
#define NVML_API_VERSION_STR "7"
#define nvmlInit nvmlInit_v2
#define nvmlDeviceGetPciInfo nvmlDeviceGetPciInfo_v2
#define nvmlDeviceGetCount nvmlDeviceGetCount_v2
#define nvmlDeviceGetHandleByIndex nvmlDeviceGetHandleByIndex_v2
#define nvmlDeviceGetHandleByPciBusId nvmlDeviceGetHandleByPciBusId_v2
/***************************************************************************************************/
/** @defgroup nvmlDeviceStructs Device Structs
* @{
*/
/***************************************************************************************************/
/**
* Special constant that some fields take when they are not available.
* Used when only part of the struct is not available.
*
* Each structure explicitly states when to check for this value.
*/
#define NVML_VALUE_NOT_AVAILABLE (-1)
typedef struct nvmlDevice_st* nvmlDevice_t;
/**
* Buffer size guaranteed to be large enough for pci bus id
*/
#define NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE 16
/**
* PCI information about a GPU device.
*/
typedef struct nvmlPciInfo_st
{
char busId[NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE]; //!< The tuple domain:bus:device.function PCI identifier (& NULL terminator)
unsigned int domain; //!< The PCI domain on which the device's bus resides, 0 to 0xffff
unsigned int bus; //!< The bus on which the device resides, 0 to 0xff
unsigned int device; //!< The device's id on the bus, 0 to 31
unsigned int pciDeviceId; //!< The combined 16-bit device id and 16-bit vendor id
// Added in NVML 2.285 API
unsigned int pciSubSystemId; //!< The 32-bit Sub System Device ID
// NVIDIA reserved for internal use only
unsigned int reserved0;
unsigned int reserved1;
unsigned int reserved2;
unsigned int reserved3;
} nvmlPciInfo_t;
/**
* Detailed ECC error counts for a device.
*
* @deprecated Different GPU families can have different memory error counters
* See \ref nvmlDeviceGetMemoryErrorCounter
*/
typedef struct nvmlEccErrorCounts_st
{
unsigned long long l1Cache; //!< L1 cache errors
unsigned long long l2Cache; //!< L2 cache errors
unsigned long long deviceMemory; //!< Device memory errors
unsigned long long registerFile; //!< Register file errors
} nvmlEccErrorCounts_t;
/**
* Utilization information for a device.
* Each sample period may be between 1 second and 1/6 second, depending on the product being queried.
*/
typedef struct nvmlUtilization_st
{
unsigned int gpu; //!< Percent of time over the past sample period during which one or more kernels was executing on the GPU
unsigned int memory; //!< Percent of time over the past sample period during which global (device) memory was being read or written
} nvmlUtilization_t;
/**
* Memory allocation information for a device.
*/
typedef struct nvmlMemory_st
{
unsigned long long total; //!< Total installed FB memory (in bytes)
unsigned long long free; //!< Unallocated FB memory (in bytes)
unsigned long long used; //!< Allocated FB memory (in bytes). Note that the driver/GPU always sets aside a small amount of memory for bookkeeping
} nvmlMemory_t;
/**
* BAR1 Memory allocation Information for a device
*/
typedef struct nvmlBAR1Memory_st
{
unsigned long long bar1Total; //!< Total BAR1 Memory (in bytes)
unsigned long long bar1Free; //!< Unallocated BAR1 Memory (in bytes)
unsigned long long bar1Used; //!< Allocated Used Memory (in bytes)
}nvmlBAR1Memory_t;
/**
* Information about running compute processes on the GPU
*/
typedef struct nvmlProcessInfo_st
{
unsigned int pid; //!< Process ID
unsigned long long usedGpuMemory; //!< Amount of used GPU memory in bytes.
//! Under WDDM, \ref NVML_VALUE_NOT_AVAILABLE is always reported
//! because Windows KMD manages all the memory and not the NVIDIA driver
} nvmlProcessInfo_t;
/**
* Enum to represent type of bridge chip
*/
typedef enum nvmlBridgeChipType_enum
{
NVML_BRIDGE_CHIP_PLX = 0,
NVML_BRIDGE_CHIP_BRO4 = 1
}nvmlBridgeChipType_t;
/**
* Maximum limit on Physical Bridges per Board
*/
#define NVML_MAX_PHYSICAL_BRIDGE (128)
/**
* Information about the Bridge Chip Firmware
*/
typedef struct nvmlBridgeChipInfo_st
{
nvmlBridgeChipType_t type; //!< Type of Bridge Chip
unsigned int fwVersion; //!< Firmware Version. 0=Version is unavailable
}nvmlBridgeChipInfo_t;
/**
* This structure stores the complete Hierarchy of the Bridge Chip within the board. The immediate
* bridge is stored at index 0 of bridgeInfoList, parent to immediate bridge is at index 1 and so forth.
*/
typedef struct nvmlBridgeChipHierarchy_st
{
unsigned char bridgeCount; //!< Number of Bridge Chips on the Board
nvmlBridgeChipInfo_t bridgeChipInfo[NVML_MAX_PHYSICAL_BRIDGE]; //!< Hierarchy of Bridge Chips on the board
}nvmlBridgeChipHierarchy_t;
/**
* Represents Type of Sampling Event
*/
typedef enum nvmlSamplingType_enum
{
NVML_TOTAL_POWER_SAMPLES = 0, //!< To represent total power drawn by GPU
NVML_GPU_UTILIZATION_SAMPLES = 1, //!< To represent percent of time during which one or more kernels was executing on the GPU
NVML_MEMORY_UTILIZATION_SAMPLES = 2, //!< To represent percent of time during which global (device) memory was being read or written
NVML_ENC_UTILIZATION_SAMPLES = 3, //!< To represent percent of time during which NVENC remains busy
NVML_DEC_UTILIZATION_SAMPLES = 4, //!< To represent percent of time during which NVDEC remains busy
NVML_PROCESSOR_CLK_SAMPLES = 5, //!< To represent processor clock samples
NVML_MEMORY_CLK_SAMPLES = 6, //!< To represent memory clock samples
// Keep this last
NVML_SAMPLINGTYPE_COUNT
}nvmlSamplingType_t;
/**
* Represents the queryable PCIe utilization counters
*/
typedef enum nvmlPcieUtilCounter_enum
{
NVML_PCIE_UTIL_TX_BYTES = 0, // 1KB granularity
NVML_PCIE_UTIL_RX_BYTES = 1, // 1KB granularity
// Keep this last
NVML_PCIE_UTIL_COUNT
} nvmlPcieUtilCounter_t;
/**
* Represents the type for sample value returned
*/
typedef enum nvmlValueType_enum
{
NVML_VALUE_TYPE_DOUBLE = 0,
NVML_VALUE_TYPE_UNSIGNED_INT = 1,
NVML_VALUE_TYPE_UNSIGNED_LONG = 2,
NVML_VALUE_TYPE_UNSIGNED_LONG_LONG = 3,
// Keep this last
NVML_VALUE_TYPE_COUNT
}nvmlValueType_t;
/**
* Union to represent different types of Value
*/
typedef union nvmlValue_st
{
double dVal; //!< If the value is double
unsigned int uiVal; //!< If the value is unsigned int
unsigned long ulVal; //!< If the value is unsigned long
unsigned long long ullVal; //!< If the value is unsigned long long
}nvmlValue_t;
/**
* Information for Sample
*/
typedef struct nvmlSample_st
{
unsigned long long timeStamp; //!< CPU Timestamp in microseconds
nvmlValue_t sampleValue; //!< Sample Value
}nvmlSample_t;
/**
* Represents type of perf policy for which violation times can be queried
*/
typedef enum nvmlPerfPolicyType_enum
{
NVML_PERF_POLICY_POWER = 0,
NVML_PERF_POLICY_THERMAL = 1,
// Keep this last
NVML_PERF_POLICY_COUNT
}nvmlPerfPolicyType_t;
/**
* Struct to hold perf policy violation status data
*/
typedef struct nvmlViolationTime_st
{
unsigned long long referenceTime; //!< referenceTime represents CPU timestamp in microseconds
unsigned long long violationTime; //!< violationTime in Nanoseconds
}nvmlViolationTime_t;
/** @} */
/***************************************************************************************************/
/** @defgroup nvmlDeviceEnumvs Device Enums
* @{
*/
/***************************************************************************************************/
/**
* Generic enable/disable enum.
*/
typedef enum nvmlEnableState_enum
{
NVML_FEATURE_DISABLED = 0, //!< Feature disabled
NVML_FEATURE_ENABLED = 1 //!< Feature enabled
} nvmlEnableState_t;
//! Generic flag used to specify the default behavior of some functions. See description of particular functions for details.
#define nvmlFlagDefault 0x00
//! Generic flag used to force some behavior. See description of particular functions for details.
#define nvmlFlagForce 0x01
/**
* * The Brand of the GPU
* */
typedef enum nvmlBrandType_enum
{
NVML_BRAND_UNKNOWN = 0,
NVML_BRAND_QUADRO = 1,
NVML_BRAND_TESLA = 2,
NVML_BRAND_NVS = 3,
NVML_BRAND_GRID = 4,
NVML_BRAND_GEFORCE = 5,
// Keep this last
NVML_BRAND_COUNT
} nvmlBrandType_t;
/**
* Temperature thresholds.
*/
typedef enum nvmlTemperatureThresholds_enum
{
NVML_TEMPERATURE_THRESHOLD_SHUTDOWN = 0, // Temperature at which the GPU will shut down
// for HW protection
NVML_TEMPERATURE_THRESHOLD_SLOWDOWN = 1, // Temperature at which the GPU will begin slowdown
// Keep this last
NVML_TEMPERATURE_THRESHOLD_COUNT
} nvmlTemperatureThresholds_t;
/**
* Temperature sensors.
*/
typedef enum nvmlTemperatureSensors_enum
{
NVML_TEMPERATURE_GPU = 0, //!< Temperature sensor for the GPU die
// Keep this last
NVML_TEMPERATURE_COUNT
} nvmlTemperatureSensors_t;
/**
* Compute mode.
*
* NVML_COMPUTEMODE_EXCLUSIVE_PROCESS was added in CUDA 4.0.
* Earlier CUDA versions supported a single exclusive mode,
* which is equivalent to NVML_COMPUTEMODE_EXCLUSIVE_THREAD in CUDA 4.0 and beyond.
*/
typedef enum nvmlComputeMode_enum
{
NVML_COMPUTEMODE_DEFAULT = 0, //!< Default compute mode -- multiple contexts per device
NVML_COMPUTEMODE_EXCLUSIVE_THREAD = 1, //!< Compute-exclusive-thread mode -- only one context per device, usable from one thread at a time
NVML_COMPUTEMODE_PROHIBITED = 2, //!< Compute-prohibited mode -- no contexts per device
NVML_COMPUTEMODE_EXCLUSIVE_PROCESS = 3, //!< Compute-exclusive-process mode -- only one context per device, usable from multiple threads at a time
// Keep this last
NVML_COMPUTEMODE_COUNT
} nvmlComputeMode_t;
/**
* ECC bit types.
*
* @deprecated See \ref nvmlMemoryErrorType_t for a more flexible type
*/
#define nvmlEccBitType_t nvmlMemoryErrorType_t
/**
* Single bit ECC errors
*
* @deprecated Mapped to \ref NVML_MEMORY_ERROR_TYPE_CORRECTED
*/
#define NVML_SINGLE_BIT_ECC NVML_MEMORY_ERROR_TYPE_CORRECTED
/**
* Double bit ECC errors
*
* @deprecated Mapped to \ref NVML_MEMORY_ERROR_TYPE_UNCORRECTED
*/
#define NVML_DOUBLE_BIT_ECC NVML_MEMORY_ERROR_TYPE_UNCORRECTED
/**
* Memory error types
*/
typedef enum nvmlMemoryErrorType_enum
{
/**
* A memory error that was corrected
*
* For ECC errors, these are single bit errors
* For Texture memory, these are errors fixed by resend
*/
NVML_MEMORY_ERROR_TYPE_CORRECTED = 0,
/**
* A memory error that was not corrected
*
* For ECC errors, these are double bit errors
* For Texture memory, these are errors where the resend fails
*/
NVML_MEMORY_ERROR_TYPE_UNCORRECTED = 1,
// Keep this last
NVML_MEMORY_ERROR_TYPE_COUNT //!< Count of memory error types
} nvmlMemoryErrorType_t;
/**
* ECC counter types.
*
* Note: Volatile counts are reset each time the driver loads. On Windows this is once per boot. On Linux this can be more frequent.
* On Linux the driver unloads when no active clients exist. If persistence mode is enabled or there is always a driver
* client active (e.g. X11), then Linux also sees per-boot behavior. If not, volatile counts are reset each time a compute app
* is run.
*/
typedef enum nvmlEccCounterType_enum
{
NVML_VOLATILE_ECC = 0, //!< Volatile counts are reset each time the driver loads.
NVML_AGGREGATE_ECC = 1, //!< Aggregate counts persist across reboots (i.e. for the lifetime of the device)
// Keep this last
NVML_ECC_COUNTER_TYPE_COUNT //!< Count of memory counter types
} nvmlEccCounterType_t;
/**
* Clock types.
*
* All speeds are in Mhz.
*/
typedef enum nvmlClockType_enum
{
NVML_CLOCK_GRAPHICS = 0, //!< Graphics clock domain
NVML_CLOCK_SM = 1, //!< SM clock domain
NVML_CLOCK_MEM = 2, //!< Memory clock domain
// Keep this last
NVML_CLOCK_COUNT //usedGpuMemory is not supported
unsigned long long time; //!< Amount of time in ms during which the compute context was active
unsigned int reserved[8];
} nvmlAccountingStats_t;
/** @} */
/***************************************************************************************************/
/** @defgroup nvmlInitializationAndCleanup Initialization and Cleanup
* This chapter describes the methods that handle NVML initialization and cleanup.
* It is the user's responsibility to call \ref nvmlInit() before calling any other methods, and
* nvmlShutdown() once NVML is no longer being used.
* @{
*/
/***************************************************************************************************/
/**
* Initialize NVML, but don't initialize any GPUs yet.
*
* \note In NVML 5.319 new nvmlInit_v2 has replaced nvmlInit"_v1" (default in NVML 4.304 and older) that
* did initialize all GPU devices in the system.
*
* This allows NVML to communicate with a GPU
* when other GPUs in the system are unstable or in a bad state. When using this API, GPUs are
* discovered and initialized in nvmlDeviceGetHandleBy* functions instead.
*
* \note To contrast nvmlInit_v2 with nvmlInit"_v1", NVML 4.304 nvmlInit"_v1" will fail when any detected GPU is in
* a bad or unstable state.
*
* For all products.
*
* This method, should be called once before invoking any other methods in the library.
* A reference count of the number of initializations is maintained. Shutdown only occurs
* when the reference count reaches zero.
*
* @return
* - \ref NVML_SUCCESS if NVML has been properly initialized
* - \ref NVML_ERROR_DRIVER_NOT_LOADED if NVIDIA driver is not running
* - \ref NVML_ERROR_NO_PERMISSION if NVML does not have permission to talk to the driver
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlInit(void);
/**
* Shut down NVML by releasing all GPU resources previously allocated with \ref nvmlInit().
*
* For all products.
*
* This method should be called after NVML work is done, once for each call to \ref nvmlInit()
* A reference count of the number of initializations is maintained. Shutdown only occurs
* when the reference count reaches zero. For backwards compatibility, no error is reported if
* nvmlShutdown() is called more times than nvmlInit().
*
* @return
* - \ref NVML_SUCCESS if NVML has been properly shut down
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlShutdown(void);
/** @} */
/***************************************************************************************************/
/** @defgroup nvmlErrorReporting Error reporting
* This chapter describes helper functions for error reporting routines.
* @{
*/
/***************************************************************************************************/
/**
* Helper method for converting NVML error codes into readable strings.
*
* For all products.
*
* @param result NVML error code to convert
*
* @return String representation of the error.
*
*/
const DECLDIR char* nvmlErrorString(nvmlReturn_t result);
/** @} */
/***************************************************************************************************/
/** @defgroup nvmlConstants Constants
* @{
*/
/***************************************************************************************************/
/**
* Buffer size guaranteed to be large enough for \ref nvmlDeviceGetInforomVersion and \ref nvmlDeviceGetInforomImageVersion
*/
#define NVML_DEVICE_INFOROM_VERSION_BUFFER_SIZE 16
/**
* Buffer size guaranteed to be large enough for \ref nvmlDeviceGetUUID
*/
#define NVML_DEVICE_UUID_BUFFER_SIZE 80
/**
* Buffer size guaranteed to be large enough for \ref nvmlSystemGetDriverVersion
*/
#define NVML_SYSTEM_DRIVER_VERSION_BUFFER_SIZE 80
/**
* Buffer size guaranteed to be large enough for \ref nvmlSystemGetNVMLVersion
*/
#define NVML_SYSTEM_NVML_VERSION_BUFFER_SIZE 80
/**
* Buffer size guaranteed to be large enough for \ref nvmlDeviceGetName
*/
#define NVML_DEVICE_NAME_BUFFER_SIZE 64
/**
* Buffer size guaranteed to be large enough for \ref nvmlDeviceGetSerial
*/
#define NVML_DEVICE_SERIAL_BUFFER_SIZE 30
/**
* Buffer size guaranteed to be large enough for \ref nvmlDeviceGetVbiosVersion
*/
#define NVML_DEVICE_VBIOS_VERSION_BUFFER_SIZE 32
/** @} */
/***************************************************************************************************/
/** @defgroup nvmlSystemQueries System Queries
* This chapter describes the queries that NVML can perform against the local system. These queries
* are not device-specific.
* @{
*/
/***************************************************************************************************/
/**
* Retrieves the version of the system's graphics driver.
*
* For all products.
*
* The version identifier is an alphanumeric string. It will not exceed 80 characters in length
* (including the NULL terminator). See \ref nvmlConstants::NVML_SYSTEM_DRIVER_VERSION_BUFFER_SIZE.
*
* @param version Reference in which to return the version identifier
* @param length The maximum allowed length of the string returned in \a version
*
* @return
* - \ref NVML_SUCCESS if \a version has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a version is NULL
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a length is too small
*/
nvmlReturn_t DECLDIR nvmlSystemGetDriverVersion(char *version, unsigned int length);
/**
* Retrieves the version of the NVML library.
*
* For all products.
*
* The version identifier is an alphanumeric string. It will not exceed 80 characters in length
* (including the NULL terminator). See \ref nvmlConstants::NVML_SYSTEM_NVML_VERSION_BUFFER_SIZE.
*
* @param version Reference in which to return the version identifier
* @param length The maximum allowed length of the string returned in \a version
*
* @return
* - \ref NVML_SUCCESS if \a version has been set
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a version is NULL
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a length is too small
*/
nvmlReturn_t DECLDIR nvmlSystemGetNVMLVersion(char *version, unsigned int length);
/**
* Gets name of the process with provided process id
*
* For all products.
*
* Returned process name is cropped to provided length.
* name string is encoded in ANSI.
*
* @param pid The identifier of the process
* @param name Reference in which to return the process name
* @param length The maximum allowed length of the string returned in \a name
*
* @return
* - \ref NVML_SUCCESS if \a name has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a name is NULL or \a length is 0.
* - \ref NVML_ERROR_NOT_FOUND if process doesn't exists
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlSystemGetProcessName(unsigned int pid, char *name, unsigned int length);
/** @} */
/***************************************************************************************************/
/** @defgroup nvmlUnitQueries Unit Queries
* This chapter describes that queries that NVML can perform against each unit. For S-class systems only.
* In each case the device is identified with an nvmlUnit_t handle. This handle is obtained by
* calling \ref nvmlUnitGetHandleByIndex().
* @{
*/
/***************************************************************************************************/
/**
* Retrieves the number of units in the system.
*
* For S-class products.
*
* @param unitCount Reference in which to return the number of units
*
* @return
* - \ref NVML_SUCCESS if \a unitCount has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a unitCount is NULL
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlUnitGetCount(unsigned int *unitCount);
/**
* Acquire the handle for a particular unit, based on its index.
*
* For S-class products.
*
* Valid indices are derived from the \a unitCount returned by \ref nvmlUnitGetCount().
* For example, if \a unitCount is 2 the valid indices are 0 and 1, corresponding to UNIT 0 and UNIT 1.
*
* The order in which NVML enumerates units has no guarantees of consistency between reboots.
*
* @param index The index of the target unit, >= 0 and < \a unitCount
* @param unit Reference in which to return the unit handle
*
* @return
* - \ref NVML_SUCCESS if \a unit has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a index is invalid or \a unit is NULL
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlUnitGetHandleByIndex(unsigned int index, nvmlUnit_t *unit);
/**
* Retrieves the static information associated with a unit.
*
* For S-class products.
*
* See \ref nvmlUnitInfo_t for details on available unit info.
*
* @param unit The identifier of the target unit
* @param info Reference in which to return the unit information
*
* @return
* - \ref NVML_SUCCESS if \a info has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a unit is invalid or \a info is NULL
*/
nvmlReturn_t DECLDIR nvmlUnitGetUnitInfo(nvmlUnit_t unit, nvmlUnitInfo_t *info);
/**
* Retrieves the LED state associated with this unit.
*
* For S-class products.
*
* See \ref nvmlLedState_t for details on allowed states.
*
* @param unit The identifier of the target unit
* @param state Reference in which to return the current LED state
*
* @return
* - \ref NVML_SUCCESS if \a state has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a unit is invalid or \a state is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if this is not an S-class product
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlUnitSetLedState()
*/
nvmlReturn_t DECLDIR nvmlUnitGetLedState(nvmlUnit_t unit, nvmlLedState_t *state);
/**
* Retrieves the PSU stats for the unit.
*
* For S-class products.
*
* See \ref nvmlPSUInfo_t for details on available PSU info.
*
* @param unit The identifier of the target unit
* @param psu Reference in which to return the PSU information
*
* @return
* - \ref NVML_SUCCESS if \a psu has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a unit is invalid or \a psu is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if this is not an S-class product
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlUnitGetPsuInfo(nvmlUnit_t unit, nvmlPSUInfo_t *psu);
/**
* Retrieves the temperature readings for the unit, in degrees C.
*
* For S-class products.
*
* Depending on the product, readings may be available for intake (type=0),
* exhaust (type=1) and board (type=2).
*
* @param unit The identifier of the target unit
* @param type The type of reading to take
* @param temp Reference in which to return the intake temperature
*
* @return
* - \ref NVML_SUCCESS if \a temp has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a unit or \a type is invalid or \a temp is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if this is not an S-class product
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlUnitGetTemperature(nvmlUnit_t unit, unsigned int type, unsigned int *temp);
/**
* Retrieves the fan speed readings for the unit.
*
* For S-class products.
*
* See \ref nvmlUnitFanSpeeds_t for details on available fan speed info.
*
* @param unit The identifier of the target unit
* @param fanSpeeds Reference in which to return the fan speed information
*
* @return
* - \ref NVML_SUCCESS if \a fanSpeeds has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a unit is invalid or \a fanSpeeds is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if this is not an S-class product
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlUnitGetFanSpeedInfo(nvmlUnit_t unit, nvmlUnitFanSpeeds_t *fanSpeeds);
/**
* Retrieves the set of GPU devices that are attached to the specified unit.
*
* For S-class products.
*
* The \a deviceCount argument is expected to be set to the size of the input \a devices array.
*
* @param unit The identifier of the target unit
* @param deviceCount Reference in which to provide the \a devices array size, and
* to return the number of attached GPU devices
* @param devices Reference in which to return the references to the attached GPU devices
*
* @return
* - \ref NVML_SUCCESS if \a deviceCount and \a devices have been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a deviceCount indicates that the \a devices array is too small
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a unit is invalid, either of \a deviceCount or \a devices is NULL
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlUnitGetDevices(nvmlUnit_t unit, unsigned int *deviceCount, nvmlDevice_t *devices);
/**
* Retrieves the IDs and firmware versions for any Host Interface Cards (HICs) in the system.
*
* For S-class products.
*
* The \a hwbcCount argument is expected to be set to the size of the input \a hwbcEntries array.
* The HIC must be connected to an S-class system for it to be reported by this function.
*
* @param hwbcCount Size of hwbcEntries array
* @param hwbcEntries Array holding information about hwbc
*
* @return
* - \ref NVML_SUCCESS if \a hwbcCount and \a hwbcEntries have been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if either \a hwbcCount or \a hwbcEntries is NULL
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a hwbcCount indicates that the \a hwbcEntries array is too small
*/
nvmlReturn_t DECLDIR nvmlSystemGetHicVersion(unsigned int *hwbcCount, nvmlHwbcEntry_t *hwbcEntries);
/** @} */
/***************************************************************************************************/
/** @defgroup nvmlDeviceQueries Device Queries
* This chapter describes that queries that NVML can perform against each device.
* In each case the device is identified with an nvmlDevice_t handle. This handle is obtained by
* calling one of \ref nvmlDeviceGetHandleByIndex(), \ref nvmlDeviceGetHandleBySerial(),
* \ref nvmlDeviceGetHandleByPciBusId(). or \ref nvmlDeviceGetHandleByUUID().
* @{
*/
/***************************************************************************************************/
/**
* Retrieves the number of compute devices in the system. A compute device is a single GPU.
*
* For all products.
*
* Note: New nvmlDeviceGetCount_v2 (default in NVML 5.319) returns count of all devices in the system
* even if nvmlDeviceGetHandleByIndex_v2 returns NVML_ERROR_NO_PERMISSION for such device.
* Update your code to handle this error, or use NVML 4.304 or older nvml header file.
* For backward binary compatibility reasons _v1 version of the API is still present in the shared
* library.
* Old _v1 version of nvmlDeviceGetCount doesn't count devices that NVML has no permission to talk to.
*
* @param deviceCount Reference in which to return the number of accessible devices
*
* @return
* - \ref NVML_SUCCESS if \a deviceCount has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a deviceCount is NULL
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetCount(unsigned int *deviceCount);
/**
* Acquire the handle for a particular device, based on its index.
*
* For all products.
*
* Valid indices are derived from the \a accessibleDevices count returned by
* \ref nvmlDeviceGetCount(). For example, if \a accessibleDevices is 2 the valid indices
* are 0 and 1, corresponding to GPU 0 and GPU 1.
*
* The order in which NVML enumerates devices has no guarantees of consistency between reboots. For that reason it
* is recommended that devices be looked up by their PCI ids or UUID. See
* \ref nvmlDeviceGetHandleByUUID() and \ref nvmlDeviceGetHandleByPciBusId().
*
* Note: The NVML index may not correlate with other APIs, such as the CUDA device index.
*
* Starting from NVML 5, this API causes NVML to initialize the target GPU
* NVML may initialize additional GPUs if:
* - The target GPU is an SLI slave
*
* Note: New nvmlDeviceGetCount_v2 (default in NVML 5.319) returns count of all devices in the system
* even if nvmlDeviceGetHandleByIndex_v2 returns NVML_ERROR_NO_PERMISSION for such device.
* Update your code to handle this error, or use NVML 4.304 or older nvml header file.
* For backward binary compatibility reasons _v1 version of the API is still present in the shared
* library.
* Old _v1 version of nvmlDeviceGetCount doesn't count devices that NVML has no permission to talk to.
*
* This means that nvmlDeviceGetHandleByIndex_v2 and _v1 can return different devices for the same index.
* If you don't touch macros that map old (_v1) versions to _v2 versions at the top of the file you don't
* need to worry about that.
*
* @param index The index of the target GPU, >= 0 and < \a accessibleDevices
* @param device Reference in which to return the device handle
*
* @return
* - \ref NVML_SUCCESS if \a device has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a index is invalid or \a device is NULL
* - \ref NVML_ERROR_INSUFFICIENT_POWER if any attached devices have improperly attached external power cables
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to talk to this device
* - \ref NVML_ERROR_IRQ_ISSUE if NVIDIA kernel detected an interrupt issue with the attached GPUs
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetIndex
* @see nvmlDeviceGetCount
*/
nvmlReturn_t DECLDIR nvmlDeviceGetHandleByIndex(unsigned int index, nvmlDevice_t *device);
/**
* Acquire the handle for a particular device, based on its board serial number.
*
* For Fermi &tm; or newer fully supported devices.
*
* This number corresponds to the value printed directly on the board, and to the value returned by
* \ref nvmlDeviceGetSerial().
*
* @deprecated Since more than one GPU can exist on a single board this function is deprecated in favor
* of \ref nvmlDeviceGetHandleByUUID.
* For dual GPU boards this function will return NVML_ERROR_INVALID_ARGUMENT.
*
* Starting from NVML 5, this API causes NVML to initialize the target GPU
* NVML may initialize additional GPUs as it searches for the target GPU
*
* @param serial The board serial number of the target GPU
* @param device Reference in which to return the device handle
*
* @return
* - \ref NVML_SUCCESS if \a device has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a serial is invalid, \a device is NULL or more than one
* device has the same serial (dual GPU boards)
* - \ref NVML_ERROR_NOT_FOUND if \a serial does not match a valid device on the system
* - \ref NVML_ERROR_INSUFFICIENT_POWER if any attached devices have improperly attached external power cables
* - \ref NVML_ERROR_IRQ_ISSUE if NVIDIA kernel detected an interrupt issue with the attached GPUs
* - \ref NVML_ERROR_GPU_IS_LOST if any GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetSerial
* @see nvmlDeviceGetHandleByUUID
*/
nvmlReturn_t DECLDIR nvmlDeviceGetHandleBySerial(const char *serial, nvmlDevice_t *device);
/**
* Acquire the handle for a particular device, based on its globally unique immutable UUID associated with each device.
*
* For all products.
*
* @param uuid The UUID of the target GPU
* @param device Reference in which to return the device handle
*
* Starting from NVML 5, this API causes NVML to initialize the target GPU
* NVML may initialize additional GPUs as it searches for the target GPU
*
* @return
* - \ref NVML_SUCCESS if \a device has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a uuid is invalid or \a device is null
* - \ref NVML_ERROR_NOT_FOUND if \a uuid does not match a valid device on the system
* - \ref NVML_ERROR_INSUFFICIENT_POWER if any attached devices have improperly attached external power cables
* - \ref NVML_ERROR_IRQ_ISSUE if NVIDIA kernel detected an interrupt issue with the attached GPUs
* - \ref NVML_ERROR_GPU_IS_LOST if any GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetUUID
*/
nvmlReturn_t DECLDIR nvmlDeviceGetHandleByUUID(const char *uuid, nvmlDevice_t *device);
/**
* Acquire the handle for a particular device, based on its PCI bus id.
*
* For all products.
*
* This value corresponds to the nvmlPciInfo_t::busId returned by \ref nvmlDeviceGetPciInfo().
*
* Starting from NVML 5, this API causes NVML to initialize the target GPU
* NVML may initialize additional GPUs if:
* - The target GPU is an SLI slave
*
* \note NVML 4.304 and older version of nvmlDeviceGetHandleByPciBusId"_v1" returns NVML_ERROR_NOT_FOUND
* instead of NVML_ERROR_NO_PERMISSION.
*
* @param pciBusId The PCI bus id of the target GPU
* @param device Reference in which to return the device handle
*
* @return
* - \ref NVML_SUCCESS if \a device has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a pciBusId is invalid or \a device is NULL
* - \ref NVML_ERROR_NOT_FOUND if \a pciBusId does not match a valid device on the system
* - \ref NVML_ERROR_INSUFFICIENT_POWER if the attached device has improperly attached external power cables
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to talk to this device
* - \ref NVML_ERROR_IRQ_ISSUE if NVIDIA kernel detected an interrupt issue with the attached GPUs
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetHandleByPciBusId(const char *pciBusId, nvmlDevice_t *device);
/**
* Retrieves the name of this device.
*
* For all products.
*
* The name is an alphanumeric string that denotes a particular product, e.g. Tesla &tm; C2070. It will not
* exceed 64 characters in length (including the NULL terminator). See \ref
* nvmlConstants::NVML_DEVICE_NAME_BUFFER_SIZE.
*
* @param device The identifier of the target device
* @param name Reference in which to return the product name
* @param length The maximum allowed length of the string returned in \a name
*
* @return
* - \ref NVML_SUCCESS if \a name has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a name is NULL
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a length is too small
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetName(nvmlDevice_t device, char *name, unsigned int length);
/**
* Retrieves the brand of this device.
*
* For all products.
*
* The type is a member of \ref nvmlBrandType_t defined above.
*
* @param device The identifier of the target device
* @param type Reference in which to return the product brand type
*
* @return
* - \ref NVML_SUCCESS if \a name has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a type is NULL
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetBrand(nvmlDevice_t device, nvmlBrandType_t *type);
/**
* Retrieves the NVML index of this device.
*
* For all products.
*
* Valid indices are derived from the \a accessibleDevices count returned by
* \ref nvmlDeviceGetCount(). For example, if \a accessibleDevices is 2 the valid indices
* are 0 and 1, corresponding to GPU 0 and GPU 1.
*
* The order in which NVML enumerates devices has no guarantees of consistency between reboots. For that reason it
* is recommended that devices be looked up by their PCI ids or GPU UUID. See
* \ref nvmlDeviceGetHandleByPciBusId() and \ref nvmlDeviceGetHandleByUUID().
*
* Note: The NVML index may not correlate with other APIs, such as the CUDA device index.
*
* @param device The identifier of the target device
* @param index Reference in which to return the NVML index of the device
*
* @return
* - \ref NVML_SUCCESS if \a index has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a index is NULL
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetHandleByIndex()
* @see nvmlDeviceGetCount()
*/
nvmlReturn_t DECLDIR nvmlDeviceGetIndex(nvmlDevice_t device, unsigned int *index);
/**
* Retrieves the globally unique board serial number associated with this device's board.
*
* For all products with an inforom.
*
* The serial number is an alphanumeric string that will not exceed 30 characters (including the NULL terminator).
* This number matches the serial number tag that is physically attached to the board. See \ref
* nvmlConstants::NVML_DEVICE_SERIAL_BUFFER_SIZE.
*
* @param device The identifier of the target device
* @param serial Reference in which to return the board/module serial number
* @param length The maximum allowed length of the string returned in \a serial
*
* @return
* - \ref NVML_SUCCESS if \a serial has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a serial is NULL
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a length is too small
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetSerial(nvmlDevice_t device, char *serial, unsigned int length);
/**
* Retrieves an array of unsigned ints (sized to cpuSetSize) of bitmasks with the ideal CPU affinity for the device
* For example, if processors 0, 1, 32, and 33 are ideal for the device and cpuSetSize == 2,
* result[0] = 0x3, result[1] = 0x3
*
* For Kepler &tm; or newer fully supported devices.
* Supported on Linux only.
*
* @param device The identifier of the target device
* @param cpuSetSize The size of the cpuSet array that is safe to access
* @param cpuSet Array reference in which to return a bitmask of CPUs, 64 CPUs per
* unsigned long on 64-bit machines, 32 on 32-bit machines
*
* @return
* - \ref NVML_SUCCESS if \a cpuAffinity has been filled
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, cpuSetSize == 0, or cpuSet is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetCpuAffinity(nvmlDevice_t device, unsigned int cpuSetSize, unsigned long *cpuSet);
/**
* Sets the ideal affinity for a device using the guidelines given in nvmlDeviceGetCpuAffinity()
* Currently supports up to 64 processors.
*
* For Kepler &tm; or newer fully supported devices.
* Supported on Linux only.
*
* @param device The identifier of the target device
*
* @return
* - \ref NVML_SUCCESS if the calling process has been successfully bound
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceSetCpuAffinity(nvmlDevice_t device);
/**
* Clear all affinity bindings
*
* For Kepler &tm; or newer fully supported devices.
* Supported on Linux only.
*
* @param device The identifier of the target device
*
* @return
* - \ref NVML_SUCCESS if the calling process has been successfully unbound
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceClearCpuAffinity(nvmlDevice_t device);
/**
* Retrieves the globally unique immutable UUID associated with this device, as a 5 part hexadecimal string,
* that augments the immutable, board serial identifier.
*
* For all products.
*
* The UUID is a globally unique identifier. It is the only available identifier for pre-Fermi-architecture products.
* It does NOT correspond to any identifier printed on the board. It will not exceed 80 characters in length
* (including the NULL terminator). See \ref nvmlConstants::NVML_DEVICE_UUID_BUFFER_SIZE.
*
* @param device The identifier of the target device
* @param uuid Reference in which to return the GPU UUID
* @param length The maximum allowed length of the string returned in \a uuid
*
* @return
* - \ref NVML_SUCCESS if \a uuid has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a uuid is NULL
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a length is too small
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetUUID(nvmlDevice_t device, char *uuid, unsigned int length);
/**
* Retrieves minor number for the device. The minor number for the device is such that the Nvidia device node file for
* each GPU will have the form /dev/nvidia[minor number].
*
* For all products.
* Supported only for Linux
*
* @param device The identifier of the target device
* @param minorNumber Reference in which to return the minor number for the device
* @return
* - \ref NVML_SUCCESS if the minor number is successfully retrieved
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a minorNumber is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetMinorNumber(nvmlDevice_t device, unsigned int *minorNumber);
/**
* Retrieves the version information for the device's infoROM object.
*
* For all products with an inforom.
*
* Fermi and higher parts have non-volatile on-board memory for persisting device info, such as aggregate
* ECC counts. The version of the data structures in this memory may change from time to time. It will not
* exceed 16 characters in length (including the NULL terminator).
* See \ref nvmlConstants::NVML_DEVICE_INFOROM_VERSION_BUFFER_SIZE.
*
* See \ref nvmlInforomObject_t for details on the available infoROM objects.
*
* @param device The identifier of the target device
* @param object The target infoROM object
* @param version Reference in which to return the infoROM version
* @param length The maximum allowed length of the string returned in \a version
*
* @return
* - \ref NVML_SUCCESS if \a version has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a version is NULL
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a length is too small
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not have an infoROM
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetInforomImageVersion
*/
nvmlReturn_t DECLDIR nvmlDeviceGetInforomVersion(nvmlDevice_t device, nvmlInforomObject_t object, char *version, unsigned int length);
/**
* Retrieves the global infoROM image version
*
* For all products with an inforom.
*
* Image version just like VBIOS version uniquely describes the exact version of the infoROM flashed on the board
* in contrast to infoROM object version which is only an indicator of supported features.
* Version string will not exceed 16 characters in length (including the NULL terminator).
* See \ref nvmlConstants::NVML_DEVICE_INFOROM_VERSION_BUFFER_SIZE.
*
* @param device The identifier of the target device
* @param version Reference in which to return the infoROM image version
* @param length The maximum allowed length of the string returned in \a version
*
* @return
* - \ref NVML_SUCCESS if \a version has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a version is NULL
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a length is too small
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not have an infoROM
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetInforomVersion
*/
nvmlReturn_t DECLDIR nvmlDeviceGetInforomImageVersion(nvmlDevice_t device, char *version, unsigned int length);
/**
* Retrieves the checksum of the configuration stored in the device's infoROM.
*
* For all products with an inforom.
*
* Can be used to make sure that two GPUs have the exact same configuration.
* Current checksum takes into account configuration stored in PWR and ECC infoROM objects.
* Checksum can change between driver releases or when user changes configuration (e.g. disable/enable ECC)
*
* @param device The identifier of the target device
* @param checksum Reference in which to return the infoROM configuration checksum
*
* @return
* - \ref NVML_SUCCESS if \a checksum has been set
* - \ref NVML_ERROR_CORRUPTED_INFOROM if the device's checksum couldn't be retrieved due to infoROM corruption
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a checksum is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetInforomConfigurationChecksum(nvmlDevice_t device, unsigned int *checksum);
/**
* Reads the infoROM from the flash and verifies the checksums.
*
* For all products with an inforom.
*
* @param device The identifier of the target device
*
* @return
* - \ref NVML_SUCCESS if infoROM is not corrupted
* - \ref NVML_ERROR_CORRUPTED_INFOROM if the device's infoROM is corrupted
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceValidateInforom(nvmlDevice_t device);
/**
* Retrieves the display mode for the device.
*
* For all products.
*
* This method indicates whether a physical display (e.g. monitor) is currently connected to
* any of the device's connectors.
*
* See \ref nvmlEnableState_t for details on allowed modes.
*
* @param device The identifier of the target device
* @param display Reference in which to return the display mode
*
* @return
* - \ref NVML_SUCCESS if \a display has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a display is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetDisplayMode(nvmlDevice_t device, nvmlEnableState_t *display);
/**
* Retrieves the display active state for the device.
*
* For all products.
*
* This method indicates whether a display is initialized on the device.
* For example whether X Server is attached to this device and has allocated memory for the screen.
*
* Display can be active even when no monitor is physically attached.
*
* See \ref nvmlEnableState_t for details on allowed modes.
*
* @param device The identifier of the target device
* @param isActive Reference in which to return the display active state
*
* @return
* - \ref NVML_SUCCESS if \a isActive has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a isActive is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetDisplayActive(nvmlDevice_t device, nvmlEnableState_t *isActive);
/**
* Retrieves the persistence mode associated with this device.
*
* For all products.
* For Linux only.
*
* When driver persistence mode is enabled the driver software state is not torn down when the last
* client disconnects. By default this feature is disabled.
*
* See \ref nvmlEnableState_t for details on allowed modes.
*
* @param device The identifier of the target device
* @param mode Reference in which to return the current driver persistence mode
*
* @return
* - \ref NVML_SUCCESS if \a mode has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a mode is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceSetPersistenceMode()
*/
nvmlReturn_t DECLDIR nvmlDeviceGetPersistenceMode(nvmlDevice_t device, nvmlEnableState_t *mode);
/**
* Retrieves the PCI attributes of this device.
*
* For all products.
*
* See \ref nvmlPciInfo_t for details on the available PCI info.
*
* @param device The identifier of the target device
* @param pci Reference in which to return the PCI info
*
* @return
* - \ref NVML_SUCCESS if \a pci has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a pci is NULL
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetPciInfo(nvmlDevice_t device, nvmlPciInfo_t *pci);
/**
* Retrieves the maximum PCIe link generation possible with this device and system
*
* I.E. for a generation 2 PCIe device attached to a generation 1 PCIe bus the max link generation this function will
* report is generation 1.
*
* For Fermi &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param maxLinkGen Reference in which to return the max PCIe link generation
*
* @return
* - \ref NVML_SUCCESS if \a maxLinkGen has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a maxLinkGen is null
* - \ref NVML_ERROR_NOT_SUPPORTED if PCIe link information is not available
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetMaxPcieLinkGeneration(nvmlDevice_t device, unsigned int *maxLinkGen);
/**
* Retrieves the maximum PCIe link width possible with this device and system
*
* I.E. for a device with a 16x PCIe bus width attached to a 8x PCIe system bus this function will report
* a max link width of 8.
*
* For Fermi &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param maxLinkWidth Reference in which to return the max PCIe link generation
*
* @return
* - \ref NVML_SUCCESS if \a maxLinkWidth has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a maxLinkWidth is null
* - \ref NVML_ERROR_NOT_SUPPORTED if PCIe link information is not available
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetMaxPcieLinkWidth(nvmlDevice_t device, unsigned int *maxLinkWidth);
/**
* Retrieves the current PCIe link generation
*
* For Fermi &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param currLinkGen Reference in which to return the current PCIe link generation
*
* @return
* - \ref NVML_SUCCESS if \a currLinkGen has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a currLinkGen is null
* - \ref NVML_ERROR_NOT_SUPPORTED if PCIe link information is not available
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetCurrPcieLinkGeneration(nvmlDevice_t device, unsigned int *currLinkGen);
/**
* Retrieves the current PCIe link width
*
* For Fermi &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param currLinkWidth Reference in which to return the current PCIe link generation
*
* @return
* - \ref NVML_SUCCESS if \a currLinkWidth has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a currLinkWidth is null
* - \ref NVML_ERROR_NOT_SUPPORTED if PCIe link information is not available
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetCurrPcieLinkWidth(nvmlDevice_t device, unsigned int *currLinkWidth);
/**
* Retrieve PCIe utilization information.
* This function is querying a byte counter over a 20ms interval and thus is the
* PCIe throughput over that interval.
*
* For Maxwell &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param counter The specific counter that should be queried \ref nvmlPcieUtilCounter_t
* @param value Reference in which to return throughput in KB/s
*
* @return
* - \ref NVML_SUCCESS if \a value has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device or \a counter is invalid, or \a value is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetPcieThroughput(nvmlDevice_t device, nvmlPcieUtilCounter_t counter, unsigned int *value);
/**
* Retrieve the PCIe replay counter and rollover information
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param value Reference in which to return the counter's value
*
* @return
* - \ref NVML_SUCCESS if \a value and \a rollover have been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a value or \a rollover are NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetPcieReplayCounter(nvmlDevice_t device, unsigned int *value);
/**
* Retrieves the current clock speeds for the device.
*
* For Fermi &tm; or newer fully supported devices.
*
* See \ref nvmlClockType_t for details on available clock information.
*
* @param device The identifier of the target device
* @param type Identify which clock domain to query
* @param clock Reference in which to return the clock speed in MHz
*
* @return
* - \ref NVML_SUCCESS if \a clock has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a clock is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device cannot report the specified clock
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetClockInfo(nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock);
/**
* Retrieves the maximum clock speeds for the device.
*
* For Fermi &tm; or newer fully supported devices.
*
* See \ref nvmlClockType_t for details on available clock information.
*
* \note On GPUs from Fermi family current P0 clocks (reported by \ref nvmlDeviceGetClockInfo) can differ from max clocks
* by few MHz.
*
* @param device The identifier of the target device
* @param type Identify which clock domain to query
* @param clock Reference in which to return the clock speed in MHz
*
* @return
* - \ref NVML_SUCCESS if \a clock has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a clock is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device cannot report the specified clock
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetMaxClockInfo(nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock);
/**
* Retrieves the current setting of a clock that applications will use unless an overspec situation occurs.
* Can be changed using \ref nvmlDeviceSetApplicationsClocks.
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param clockType Identify which clock domain to query
* @param clockMHz Reference in which to return the clock in MHz
*
* @return
* - \ref NVML_SUCCESS if \a clockMHz has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a clockMHz is NULL or \a clockType is invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetApplicationsClock(nvmlDevice_t device, nvmlClockType_t clockType, unsigned int *clockMHz);
/**
* Retrieves the default applications clock that GPU boots with or
* defaults to after \ref nvmlDeviceResetApplicationsClocks call.
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param clockType Identify which clock domain to query
* @param clockMHz Reference in which to return the default clock in MHz
*
* @return
* - \ref NVML_SUCCESS if \a clockMHz has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a clockMHz is NULL or \a clockType is invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* \see nvmlDeviceGetApplicationsClock
*/
nvmlReturn_t DECLDIR nvmlDeviceGetDefaultApplicationsClock(nvmlDevice_t device, nvmlClockType_t clockType, unsigned int *clockMHz);
/**
* Resets the application clock to the default value
*
* This is the applications clock that will be used after system reboot or driver reload.
* Default value is constant, but the current value an be changed using \ref nvmlDeviceSetApplicationsClocks.
*
* @see nvmlDeviceGetApplicationsClock
* @see nvmlDeviceSetApplicationsClocks
*
* For Fermi &tm; or newer non-GeForce fully supported devices and Maxwell or newer GeForce devices.
*
* @param device The identifier of the target device
*
* @return
* - \ref NVML_SUCCESS if new settings were successfully set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceResetApplicationsClocks(nvmlDevice_t device);
/**
* Retrieves the list of possible memory clocks that can be used as an argument for \ref nvmlDeviceSetApplicationsClocks.
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param count Reference in which to provide the \a clocksMHz array size, and
* to return the number of elements
* @param clocksMHz Reference in which to return the clock in MHz
*
* @return
* - \ref NVML_SUCCESS if \a count and \a clocksMHz have been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a count is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a count is too small (\a count is set to the number of
* required elements)
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceSetApplicationsClocks
* @see nvmlDeviceGetSupportedGraphicsClocks
*/
nvmlReturn_t DECLDIR nvmlDeviceGetSupportedMemoryClocks(nvmlDevice_t device, unsigned int *count, unsigned int *clocksMHz);
/**
* Retrieves the list of possible graphics clocks that can be used as an argument for \ref nvmlDeviceSetApplicationsClocks.
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param memoryClockMHz Memory clock for which to return possible graphics clocks
* @param count Reference in which to provide the \a clocksMHz array size, and
* to return the number of elements
* @param clocksMHz Reference in which to return the clocks in MHz
*
* @return
* - \ref NVML_SUCCESS if \a count and \a clocksMHz have been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_NOT_FOUND if the specified \a memoryClockMHz is not a supported frequency
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a clock is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a count is too small
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceSetApplicationsClocks
* @see nvmlDeviceGetSupportedMemoryClocks
*/
nvmlReturn_t DECLDIR nvmlDeviceGetSupportedGraphicsClocks(nvmlDevice_t device, unsigned int memoryClockMHz, unsigned int *count, unsigned int *clocksMHz);
/**
* Retrieve the current state of auto boosted clocks on a device and store it in \a isEnabled
*
* For Kepler &tm; or newer fully supported devices.
*
* Auto boosted clocks are enabled by default on some hardware, allowing the GPU to run at higher clock rates
* to maximize performance as thermal limits allow.
*
* @param device The identifier of the target device
* @param isEnabled Where to store the current state of auto boosted clocks of the target device
* @param defaultIsEnabled Where to store the default auto boosted clocks behavior of the target device that the device will
* revert to when no applications are using the GPU
*
* @return
* - \ref NVML_SUCCESS If \a isEnabled has been been set with the auto boosted clocks state of \a device
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a isEnabled is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support auto boosted clocks
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
*/
nvmlReturn_t DECLDIR nvmlDeviceGetAutoBoostedClocksEnabled(nvmlDevice_t device, nvmlEnableState_t *isEnabled, nvmlEnableState_t *defaultIsEnabled);
/**
* Try to set the current state of auto boosted clocks on a device.
*
* For Kepler &tm; or newer fully supported devices.
*
* Auto boosted clocks are enabled by default on some hardware, allowing the GPU to run at higher clock rates
* to maximize performance as thermal limits allow. Auto boosted clocks should be disabled if fixed clock
* rates are desired.
* Non-root users may use this API by default but can be restricted by root from using this API by calling
* \ref nvmlDeviceSetAPIRestriction with apiType=NVML_RESTRICTED_API_SET_AUTO_BOOSTED_CLOCKS.
*
* @param device The identifier of the target device
* @param enabled What state to try to set auto boosted clocks of the target device to
*
* @return
* - \ref NVML_SUCCESS If the auto boosted clocks were successfully set to the state specified by \a enabled
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support auto boosted clocks
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
*/
nvmlReturn_t DECLDIR nvmlDeviceSetAutoBoostedClocksEnabled(nvmlDevice_t device, nvmlEnableState_t enabled);
/**
* Try to set the default state of auto boosted clocks on a device. This is the default state that auto boosted clocks will
* return to when no compute running processes (e.g. CUDA application which have an active context) are running
*
* For Kepler &tm; or newer non-GeForce fully supported devices and Maxwell or newer GeForce devices.
* Requires root/admin permissions.
*
* Auto boosted clocks are enabled by default on some hardware, allowing the GPU to run at higher clock rates
* to maximize performance as thermal limits allow. Auto boosted clocks should be disabled if fixed clock
* rates are desired.
*
* @param device The identifier of the target device
* @param enabled What state to try to set default auto boosted clocks of the target device to
* @param flags Flags that change the default behavior. Currently Unused.
*
* @return
* - \ref NVML_SUCCESS If the auto boosted clock's default state was successfully set to the state specified by \a enabled
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_NO_PERMISSION If the calling user does not have permission to change auto boosted clock's default state.
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support auto boosted clocks
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
*/
nvmlReturn_t DECLDIR nvmlDeviceSetDefaultAutoBoostedClocksEnabled(nvmlDevice_t device, nvmlEnableState_t enabled, unsigned int flags);
/**
* Retrieves the intended operating speed of the device's fan.
*
* Note: The reported speed is the intended fan speed. If the fan is physically blocked and unable to spin, the
* output will not match the actual fan speed.
*
* For all discrete products with dedicated fans.
*
* The fan speed is expressed as a percent of the maximum, i.e. full speed is 100%.
*
* @param device The identifier of the target device
* @param speed Reference in which to return the fan speed percentage
*
* @return
* - \ref NVML_SUCCESS if \a speed has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a speed is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not have a fan
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetFanSpeed(nvmlDevice_t device, unsigned int *speed);
/**
* Retrieves the current temperature readings for the device, in degrees C.
*
* For all products.
*
* See \ref nvmlTemperatureSensors_t for details on available temperature sensors.
*
* @param device The identifier of the target device
* @param sensorType Flag that indicates which sensor reading to retrieve
* @param temp Reference in which to return the temperature reading
*
* @return
* - \ref NVML_SUCCESS if \a temp has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a sensorType is invalid or \a temp is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not have the specified sensor
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetTemperature(nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp);
/**
* Retrieves the temperature threshold for the GPU with the specified threshold type in degrees C.
*
* For Kepler &tm; or newer fully supported devices.
*
* See \ref nvmlTemperatureThresholds_t for details on available temperature thresholds.
*
* @param device The identifier of the target device
* @param thresholdType The type of threshold value queried
* @param temp Reference in which to return the temperature reading
* @return
* - \ref NVML_SUCCESS if \a temp has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a thresholdType is invalid or \a temp is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not have a temperature sensor or is unsupported
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetTemperatureThreshold(nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp);
/**
* Retrieves the current performance state for the device.
*
* For Fermi &tm; or newer fully supported devices.
*
* See \ref nvmlPstates_t for details on allowed performance states.
*
* @param device The identifier of the target device
* @param pState Reference in which to return the performance state reading
*
* @return
* - \ref NVML_SUCCESS if \a pState has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a pState is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetPerformanceState(nvmlDevice_t device, nvmlPstates_t *pState);
/**
* Retrieves current clocks throttling reasons.
*
* For all fully supported products.
*
* \note More than one bit can be enabled at the same time. Multiple reasons can be affecting clocks at once.
*
* @param device The identifier of the target device
* @param clocksThrottleReasons Reference in which to return bitmask of active clocks throttle
* reasons
*
* @return
* - \ref NVML_SUCCESS if \a clocksThrottleReasons has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a clocksThrottleReasons is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlClocksThrottleReasons
* @see nvmlDeviceGetSupportedClocksThrottleReasons
*/
nvmlReturn_t DECLDIR nvmlDeviceGetCurrentClocksThrottleReasons(nvmlDevice_t device, unsigned long long *clocksThrottleReasons);
/**
* Retrieves bitmask of supported clocks throttle reasons that can be returned by
* \ref nvmlDeviceGetCurrentClocksThrottleReasons
*
* For all fully supported products.
*
* @param device The identifier of the target device
* @param supportedClocksThrottleReasons Reference in which to return bitmask of supported
* clocks throttle reasons
*
* @return
* - \ref NVML_SUCCESS if \a supportedClocksThrottleReasons has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a supportedClocksThrottleReasons is NULL
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlClocksThrottleReasons
* @see nvmlDeviceGetCurrentClocksThrottleReasons
*/
nvmlReturn_t DECLDIR nvmlDeviceGetSupportedClocksThrottleReasons(nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons);
/**
* Deprecated: Use \ref nvmlDeviceGetPerformanceState. This function exposes an incorrect generalization.
*
* Retrieve the current performance state for the device.
*
* For Fermi &tm; or newer fully supported devices.
*
* See \ref nvmlPstates_t for details on allowed performance states.
*
* @param device The identifier of the target device
* @param pState Reference in which to return the performance state reading
*
* @return
* - \ref NVML_SUCCESS if \a pState has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a pState is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetPowerState(nvmlDevice_t device, nvmlPstates_t *pState);
/**
* This API has been deprecated.
*
* Retrieves the power management mode associated with this device.
*
* For products from the Fermi family.
* - Requires \a NVML_INFOROM_POWER version 3.0 or higher.
*
* For from the Kepler or newer families.
* - Does not require \a NVML_INFOROM_POWER object.
*
* This flag indicates whether any power management algorithm is currently active on the device. An
* enabled state does not necessarily mean the device is being actively throttled -- only that
* that the driver will do so if the appropriate conditions are met.
*
* See \ref nvmlEnableState_t for details on allowed modes.
*
* @param device The identifier of the target device
* @param mode Reference in which to return the current power management mode
*
* @return
* - \ref NVML_SUCCESS if \a mode has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a mode is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetPowerManagementMode(nvmlDevice_t device, nvmlEnableState_t *mode);
/**
* Retrieves the power management limit associated with this device.
*
* For Fermi &tm; or newer fully supported devices.
*
* The power limit defines the upper boundary for the card's power draw. If
* the card's total power draw reaches this limit the power management algorithm kicks in.
*
* This reading is only available if power management mode is supported.
* See \ref nvmlDeviceGetPowerManagementMode.
*
* @param device The identifier of the target device
* @param limit Reference in which to return the power management limit in milliwatts
*
* @return
* - \ref NVML_SUCCESS if \a limit has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a limit is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetPowerManagementLimit(nvmlDevice_t device, unsigned int *limit);
/**
* Retrieves information about possible values of power management limits on this device.
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param minLimit Reference in which to return the minimum power management limit in milliwatts
* @param maxLimit Reference in which to return the maximum power management limit in milliwatts
*
* @return
* - \ref NVML_SUCCESS if \a minLimit and \a maxLimit have been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a minLimit or \a maxLimit is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceSetPowerManagementLimit
*/
nvmlReturn_t DECLDIR nvmlDeviceGetPowerManagementLimitConstraints(nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit);
/**
* Retrieves default power management limit on this device, in milliwatts.
* Default power management limit is a power management limit that the device boots with.
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param defaultLimit Reference in which to return the default power management limit in milliwatts
*
* @return
* - \ref NVML_SUCCESS if \a defaultLimit has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a defaultLimit is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetPowerManagementDefaultLimit(nvmlDevice_t device, unsigned int *defaultLimit);
/**
* Retrieves power usage for this GPU in milliwatts and its associated circuitry (e.g. memory)
*
* For Fermi &tm; or newer fully supported devices.
*
* On Fermi and Kepler GPUs the reading is accurate to within +/- 5% of current power draw.
*
* It is only available if power management mode is supported. See \ref nvmlDeviceGetPowerManagementMode.
*
* @param device The identifier of the target device
* @param power Reference in which to return the power usage information
*
* @return
* - \ref NVML_SUCCESS if \a power has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a power is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support power readings
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetPowerUsage(nvmlDevice_t device, unsigned int *power);
/**
* Get the effective power limit that the driver enforces after taking into account all limiters
*
* Note: This can be different from the \ref nvmlDeviceGetPowerManagementLimit if other limits are set elsewhere
* This includes the out of band power limit interface
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The device to communicate with
* @param limit Reference in which to return the power management limit in milliwatts
*
* @return
* - \ref NVML_SUCCESS if \a limit has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a limit is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetEnforcedPowerLimit(nvmlDevice_t device, unsigned int *limit);
/**
* Retrieves the current GOM and pending GOM (the one that GPU will switch to after reboot).
*
* For GK110 M-class and X-class Tesla &tm; products from the Kepler family.
* Modes \ref NVML_GOM_LOW_DP and \ref NVML_GOM_ALL_ON are supported on fully supported GeForce products.
* Not supported on Quadro ® and Tesla &tm; C-class products.
*
* @param device The identifier of the target device
* @param current Reference in which to return the current GOM
* @param pending Reference in which to return the pending GOM
*
* @return
* - \ref NVML_SUCCESS if \a mode has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a current or \a pending is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlGpuOperationMode_t
* @see nvmlDeviceSetGpuOperationMode
*/
nvmlReturn_t DECLDIR nvmlDeviceGetGpuOperationMode(nvmlDevice_t device, nvmlGpuOperationMode_t *current, nvmlGpuOperationMode_t *pending);
/**
* Retrieves the amount of used, free and total memory available on the device, in bytes.
*
* For all products.
*
* Enabling ECC reduces the amount of total available memory, due to the extra required parity bits.
* Under WDDM most device memory is allocated and managed on startup by Windows.
*
* Under Linux and Windows TCC, the reported amount of used memory is equal to the sum of memory allocated
* by all active channels on the device.
*
* See \ref nvmlMemory_t for details on available memory info.
*
* @param device The identifier of the target device
* @param memory Reference in which to return the memory information
*
* @return
* - \ref NVML_SUCCESS if \a memory has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a memory is NULL
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetMemoryInfo(nvmlDevice_t device, nvmlMemory_t *memory);
/**
* Retrieves the current compute mode for the device.
*
* For all products.
*
* See \ref nvmlComputeMode_t for details on allowed compute modes.
*
* @param device The identifier of the target device
* @param mode Reference in which to return the current compute mode
*
* @return
* - \ref NVML_SUCCESS if \a mode has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a mode is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceSetComputeMode()
*/
nvmlReturn_t DECLDIR nvmlDeviceGetComputeMode(nvmlDevice_t device, nvmlComputeMode_t *mode);
/**
* Retrieves the current and pending ECC modes for the device.
*
* For Fermi &tm; or newer fully supported devices.
* Only applicable to devices with ECC.
* Requires \a NVML_INFOROM_ECC version 1.0 or higher.
*
* Changing ECC modes requires a reboot. The "pending" ECC mode refers to the target mode following
* the next reboot.
*
* See \ref nvmlEnableState_t for details on allowed modes.
*
* @param device The identifier of the target device
* @param current Reference in which to return the current ECC mode
* @param pending Reference in which to return the pending ECC mode
*
* @return
* - \ref NVML_SUCCESS if \a current and \a pending have been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or either \a current or \a pending is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceSetEccMode()
*/
nvmlReturn_t DECLDIR nvmlDeviceGetEccMode(nvmlDevice_t device, nvmlEnableState_t *current, nvmlEnableState_t *pending);
/**
* Retrieves the device boardId from 0-N.
* Devices with the same boardId indicate GPUs connected to the same PLX. Use in conjunction with
* \ref nvmlDeviceGetMultiGpuBoard() to decide if they are on the same board as well.
* The boardId returned is a unique ID for the current configuration. Uniqueness and ordering across
* reboots and system configurations is not guaranteed (i.e. if a Tesla K40c returns 0x100 and
* the two GPUs on a Tesla K10 in the same system returns 0x200 it is not guaranteed they will
* always return those values but they will always be different from each other).
*
*
* For Fermi &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param boardId Reference in which to return the device's board ID
*
* @return
* - \ref NVML_SUCCESS if \a boardId has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a boardId is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetBoardId(nvmlDevice_t device, unsigned int *boardId);
/**
* Retrieves whether the device is on a Multi-GPU Board
* Devices that are on multi-GPU boards will set \a multiGpuBool to a non-zero value.
*
* For Fermi &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param multiGpuBool Reference in which to return a zero or non-zero value
* to indicate whether the device is on a multi GPU board
*
* @return
* - \ref NVML_SUCCESS if \a multiGpuBool has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a multiGpuBool is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetMultiGpuBoard(nvmlDevice_t device, unsigned int *multiGpuBool);
/**
* Retrieves the total ECC error counts for the device.
*
* For Fermi &tm; or newer fully supported devices.
* Only applicable to devices with ECC.
* Requires \a NVML_INFOROM_ECC version 1.0 or higher.
* Requires ECC Mode to be enabled.
*
* The total error count is the sum of errors across each of the separate memory systems, i.e. the total set of
* errors across the entire device.
*
* See \ref nvmlMemoryErrorType_t for a description of available error types.\n
* See \ref nvmlEccCounterType_t for a description of available counter types.
*
* @param device The identifier of the target device
* @param errorType Flag that specifies the type of the errors.
* @param counterType Flag that specifies the counter-type of the errors.
* @param eccCounts Reference in which to return the specified ECC errors
*
* @return
* - \ref NVML_SUCCESS if \a eccCounts has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device, \a errorType or \a counterType is invalid, or \a eccCounts is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceClearEccErrorCounts()
*/
nvmlReturn_t DECLDIR nvmlDeviceGetTotalEccErrors(nvmlDevice_t device, nvmlMemoryErrorType_t errorType, nvmlEccCounterType_t counterType, unsigned long long *eccCounts);
/**
* Retrieves the detailed ECC error counts for the device.
*
* @deprecated This API supports only a fixed set of ECC error locations
* On different GPU architectures different locations are supported
* See \ref nvmlDeviceGetMemoryErrorCounter
*
* For Fermi &tm; or newer fully supported devices.
* Only applicable to devices with ECC.
* Requires \a NVML_INFOROM_ECC version 2.0 or higher to report aggregate location-based ECC counts.
* Requires \a NVML_INFOROM_ECC version 1.0 or higher to report all other ECC counts.
* Requires ECC Mode to be enabled.
*
* Detailed errors provide separate ECC counts for specific parts of the memory system.
*
* Reports zero for unsupported ECC error counters when a subset of ECC error counters are supported.
*
* See \ref nvmlMemoryErrorType_t for a description of available bit types.\n
* See \ref nvmlEccCounterType_t for a description of available counter types.\n
* See \ref nvmlEccErrorCounts_t for a description of provided detailed ECC counts.
*
* @param device The identifier of the target device
* @param errorType Flag that specifies the type of the errors.
* @param counterType Flag that specifies the counter-type of the errors.
* @param eccCounts Reference in which to return the specified ECC errors
*
* @return
* - \ref NVML_SUCCESS if \a eccCounts has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device, \a errorType or \a counterType is invalid, or \a eccCounts is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceClearEccErrorCounts()
*/
nvmlReturn_t DECLDIR nvmlDeviceGetDetailedEccErrors(nvmlDevice_t device, nvmlMemoryErrorType_t errorType, nvmlEccCounterType_t counterType, nvmlEccErrorCounts_t *eccCounts);
/**
* Retrieves the requested memory error counter for the device.
*
* For Fermi &tm; or newer fully supported devices.
* Requires \a NVML_INFOROM_ECC version 2.0 or higher to report aggregate location-based memory error counts.
* Requires \a NVML_INFOROM_ECC version 1.0 or higher to report all other memory error counts.
*
* Only applicable to devices with ECC.
*
* Requires ECC Mode to be enabled.
*
* See \ref nvmlMemoryErrorType_t for a description of available memory error types.\n
* See \ref nvmlEccCounterType_t for a description of available counter types.\n
* See \ref nvmlMemoryLocation_t for a description of available counter locations.\n
*
* @param device The identifier of the target device
* @param errorType Flag that specifies the type of error.
* @param counterType Flag that specifies the counter-type of the errors.
* @param locationType Specifies the location of the counter.
* @param count Reference in which to return the ECC counter
*
* @return
* - \ref NVML_SUCCESS if \a count has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device, \a bitTyp,e \a counterType or \a locationType is
* invalid, or \a count is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support ECC error reporting in the specified memory
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetMemoryErrorCounter(nvmlDevice_t device, nvmlMemoryErrorType_t errorType,
nvmlEccCounterType_t counterType,
nvmlMemoryLocation_t locationType, unsigned long long *count);
/**
* Retrieves the current utilization rates for the device's major subsystems.
*
* For Fermi &tm; or newer fully supported devices.
*
* See \ref nvmlUtilization_t for details on available utilization rates.
*
* \note During driver initialization when ECC is enabled one can see high GPU and Memory Utilization readings.
* This is caused by ECC Memory Scrubbing mechanism that is performed during driver initialization.
*
* @param device The identifier of the target device
* @param utilization Reference in which to return the utilization information
*
* @return
* - \ref NVML_SUCCESS if \a utilization has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a utilization is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetUtilizationRates(nvmlDevice_t device, nvmlUtilization_t *utilization);
/**
* Retrieves the current utilization and sampling size in microseconds for the Encoder
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param utilization Reference to an unsigned int for encoder utilization info
* @param samplingPeriodUs Reference to an unsigned int for the sampling period in US
*
* @return
* - \ref NVML_SUCCESS if \a utilization has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a utilization is NULL, or \a samplingPeriodUs is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetEncoderUtilization(nvmlDevice_t device, unsigned int *utilization, unsigned int *samplingPeriodUs);
/**
* Retrieves the current utilization and sampling size in microseconds for the Decoder
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param utilization Reference to an unsigned int for decoder utilization info
* @param samplingPeriodUs Reference to an unsigned int for the sampling period in US
*
* @return
* - \ref NVML_SUCCESS if \a utilization has been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a utilization is NULL, or \a samplingPeriodUs is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetDecoderUtilization(nvmlDevice_t device, unsigned int *utilization, unsigned int *samplingPeriodUs);
/**
* Retrieves the current and pending driver model for the device.
*
* For Fermi &tm; or newer fully supported devices.
* For windows only.
*
* On Windows platforms the device driver can run in either WDDM or WDM (TCC) mode. If a display is attached
* to the device it must run in WDDM mode. TCC mode is preferred if a display is not attached.
*
* See \ref nvmlDriverModel_t for details on available driver models.
*
* @param device The identifier of the target device
* @param current Reference in which to return the current driver model
* @param pending Reference in which to return the pending driver model
*
* @return
* - \ref NVML_SUCCESS if either \a current and/or \a pending have been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or both \a current and \a pending are NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the platform is not windows
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceSetDriverModel()
*/
nvmlReturn_t DECLDIR nvmlDeviceGetDriverModel(nvmlDevice_t device, nvmlDriverModel_t *current, nvmlDriverModel_t *pending);
/**
* Get VBIOS version of the device.
*
* For all products.
*
* The VBIOS version may change from time to time. It will not exceed 32 characters in length
* (including the NULL terminator). See \ref nvmlConstants::NVML_DEVICE_VBIOS_VERSION_BUFFER_SIZE.
*
* @param device The identifier of the target device
* @param version Reference to which to return the VBIOS version
* @param length The maximum allowed length of the string returned in \a version
*
* @return
* - \ref NVML_SUCCESS if \a version has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a version is NULL
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a length is too small
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetVbiosVersion(nvmlDevice_t device, char *version, unsigned int length);
/**
* Get Bridge Chip Information for all the bridge chips on the board.
*
* For all fully supported products.
* Only applicable to multi-GPU products.
*
* @param device The identifier of the target device
* @param bridgeHierarchy Reference to the returned bridge chip Hierarchy
*
* @return
* - \ref NVML_SUCCESS if bridge chip exists
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, or \a bridgeInfo is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if bridge chip not supported on the device
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
*/
nvmlReturn_t DECLDIR nvmlDeviceGetBridgeChipInfo(nvmlDevice_t device, nvmlBridgeChipHierarchy_t *bridgeHierarchy);
/**
* Get information about processes with a compute context on a device
*
* For Kepler &tm; or newer fully supported devices.
*
* This function returns information only about compute running processes (e.g. CUDA application which have
* active context). Any graphics applications (e.g. using OpenGL, DirectX) won't be listed by this function.
*
* To query the current number of running compute processes, call this function with *infoCount = 0. The
* return code will be NVML_ERROR_INSUFFICIENT_SIZE, or NVML_SUCCESS if none are running. For this call
* \a infos is allowed to be NULL.
*
* Keep in mind that information returned by this call is dynamic and the number of elements might change in
* time. Allocate more space for \a infos table in case new compute processes are spawned.
*
* @param device The identifier of the target device
* @param infoCount Reference in which to provide the \a infos array size, and
* to return the number of returned elements
* @param infos Reference in which to return the process information
*
* @return
* - \ref NVML_SUCCESS if \a infoCount and \a infos have been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a infoCount indicates that the \a infos array is too small
* \a infoCount will contain minimal amount of space necessary for
* the call to complete
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, either of \a infoCount or \a infos is NULL
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see \ref nvmlSystemGetProcessName
*/
nvmlReturn_t DECLDIR nvmlDeviceGetComputeRunningProcesses(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_t *infos);
/**
* Get information about processes with a graphics context on a device
*
* For Kepler &tm; or newer fully supported devices.
*
* This function returns information only about graphics based processes
* (eg. applications using OpenGL, DirectX)
*
* To query the current number of running graphics processes, call this function with *infoCount = 0. The
* return code will be NVML_ERROR_INSUFFICIENT_SIZE, or NVML_SUCCESS if none are running. For this call
* \a infos is allowed to be NULL.
*
* Keep in mind that information returned by this call is dynamic and the number of elements might change in
* time. Allocate more space for \a infos table in case new graphics processes are spawned.
*
* @param device The identifier of the target device
* @param infoCount Reference in which to provide the \a infos array size, and
* to return the number of returned elements
* @param infos Reference in which to return the process information
*
* @return
* - \ref NVML_SUCCESS if \a infoCount and \a infos have been populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a infoCount indicates that the \a infos array is too small
* \a infoCount will contain minimal amount of space necessary for
* the call to complete
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, either of \a infoCount or \a infos is NULL
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see \ref nvmlSystemGetProcessName
*/
nvmlReturn_t DECLDIR nvmlDeviceGetGraphicsRunningProcesses(nvmlDevice_t device, unsigned int *infoCount, nvmlProcessInfo_t *infos);
/**
* Check if the GPU devices are on the same physical board.
*
* For all fully supported products.
*
* @param device1 The first GPU device
* @param device2 The second GPU device
* @param onSameBoard Reference in which to return the status.
* Non-zero indicates that the GPUs are on the same board.
*
* @return
* - \ref NVML_SUCCESS if \a onSameBoard has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a dev1 or \a dev2 are invalid or \a onSameBoard is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if this check is not supported by the device
* - \ref NVML_ERROR_GPU_IS_LOST if the either GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceOnSameBoard(nvmlDevice_t device1, nvmlDevice_t device2, int *onSameBoard);
/**
* Retrieves the root/admin permissions on the target API. See \a nvmlRestrictedAPI_t for the list of supported APIs.
* If an API is restricted only root users can call that API. See \a nvmlDeviceSetAPIRestriction to change current permissions.
*
* For all fully supported products.
*
* @param device The identifier of the target device
* @param apiType Target API type for this operation
* @param isRestricted Reference in which to return the current restriction
* NVML_FEATURE_ENABLED indicates that the API is root-only
* NVML_FEATURE_DISABLED indicates that the API is accessible to all users
*
* @return
* - \ref NVML_SUCCESS if \a isRestricted has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a apiType incorrect or \a isRestricted is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device or the device does not support
* the feature that is being queried (E.G. Enabling/disabling auto boosted clocks is
* not supported by the device)
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlRestrictedAPI_t
*/
nvmlReturn_t DECLDIR nvmlDeviceGetAPIRestriction(nvmlDevice_t device, nvmlRestrictedAPI_t apiType, nvmlEnableState_t *isRestricted);
/**
* Gets recent samples for the GPU.
*
* For all fully supported products.
*
* Based on type, this method can be used to fetch the power, utilization or clock samples maintained in the buffer by
* the driver.
*
* Power, Utilization and Clock samples are returned as type "unsigned int" for the union nvmlValue_t.
*
* To get the size of samples that user needs to allocate, the method is invoked with samples set to NULL.
* The returned samplesCount will provide the number of samples that can be queried. The user needs to
* allocate the buffer with size as samplesCount * sizeof(nvmlSample_t).
*
* lastSeenTimeStamp represents CPU timestamp in microseconds. Set it to 0 to fetch all the samples maintained by the
* underlying buffer. Set lastSeenTimeStamp to one of the timeStamps retrieved from the date of the previous query
* to get more recent samples.
*
* This method fetches the number of entries which can be accommodated in the provided samples array, and the
* reference samplesCount is updated to indicate how many samples were actually retrieved. The advantage of using this
* method for samples in contrast to polling via existing methods is to get get higher frequency data at lower polling cost.
*
* @param device The identifier for the target device
* @param type Type of sampling event
* @param lastSeenTimeStamp Return only samples with timestamp greater than lastSeenTimeStamp.
* @param sampleValType Output parameter to represent the type of sample value as described in nvmlSampleVal_t
* @param sampleCount Reference to provide the number of elements which can be queried in samples array
* @param samples Reference in which samples are returned
* @return
* - \ref NVML_SUCCESS if samples are successfully retrieved
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a samplesCount is NULL or
* reference to \a sampleCount is 0 for non null \a samples
* - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_NOT_FOUND if sample entries are not found
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetSamples(nvmlDevice_t device, nvmlSamplingType_t type, unsigned long long lastSeenTimeStamp,
nvmlValueType_t *sampleValType, unsigned int *sampleCount, nvmlSample_t *samples);
/**
* Gets Total, Available and Used size of BAR1 memory.
*
* BAR1 is used to map the FB (device memory) so that it can be directly accessed by the CPU or by 3rd party
* devices (peer-to-peer on the PCIE bus).
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param bar1Memory Reference in which BAR1 memory
* information is returned.
*
* @return
* - \ref NVML_SUCCESS if BAR1 memory is successfully retrieved
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a bar1Memory is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
*/
nvmlReturn_t DECLDIR nvmlDeviceGetBAR1MemoryInfo(nvmlDevice_t device, nvmlBAR1Memory_t *bar1Memory);
/**
* Gets the duration of time during which the device was throttled (lower than requested clocks) due to power
* or thermal constraints.
*
* The method is important to users who are tying to understand if their GPUs throttle at any point during their applications. The
* difference in violation times at two different reference times gives the indication of GPU throttling event.
*
* Violation for thermal capping is not supported at this time.
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param perfPolicyType Represents Performance policy which can trigger GPU throttling
* @param violTime Reference to which violation time related information is returned
*
*
* @return
* - \ref NVML_SUCCESS if violation time is successfully retrieved
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a perfPolicyType is invalid, or \a violTime is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if this query is not supported by the device
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
*
*/
nvmlReturn_t DECLDIR nvmlDeviceGetViolationStatus(nvmlDevice_t device, nvmlPerfPolicyType_t perfPolicyType, nvmlViolationTime_t *violTime);
/**
* @}
*/
/** @addtogroup nvmlAccountingStats
* @{
*/
/**
* Queries the state of per process accounting mode.
*
* For Kepler &tm; or newer fully supported devices.
*
* See \ref nvmlDeviceGetAccountingStats for more details.
* See \ref nvmlDeviceSetAccountingMode
*
* @param device The identifier of the target device
* @param mode Reference in which to return the current accounting mode
*
* @return
* - \ref NVML_SUCCESS if the mode has been successfully retrieved
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a mode are NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetAccountingMode(nvmlDevice_t device, nvmlEnableState_t *mode);
/**
* Queries process's accounting stats.
*
* For Kepler &tm; or newer fully supported devices.
*
* Accounting stats capture GPU utilization and other statistics across the lifetime of a process.
* Accounting stats can be queried during life time of the process and after its termination.
* Accounting stats are kept in a circular buffer, newly created processes overwrite information about old
* processes.
*
* See \ref nvmlAccountingStats_t for description of each returned metric.
* List of processes that can be queried can be retrieved from \ref nvmlDeviceGetAccountingPids.
*
* @note Accounting Mode needs to be on. See \ref nvmlDeviceGetAccountingMode.
* @note Only compute and graphics applications stats can be queried. Monitoring applications stats can't be
* queried since they don't contribute to GPU utilization.
* @note In case of pid collision stats of only the latest process (that terminated last) will be reported
*
* @warning On Kepler devices per process statistics are accurate only if there's one process running on a GPU.
*
* @param device The identifier of the target device
* @param pid Process Id of the target process to query stats for
* @param stats Reference in which to return the process's accounting stats
*
* @return
* - \ref NVML_SUCCESS if stats have been successfully retrieved
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a stats are NULL
* - \ref NVML_ERROR_NOT_FOUND if process stats were not found
* - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature or accounting mode is disabled
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetAccountingBufferSize
*/
nvmlReturn_t DECLDIR nvmlDeviceGetAccountingStats(nvmlDevice_t device, unsigned int pid, nvmlAccountingStats_t *stats);
/**
* Queries list of processes that can be queried for accounting stats.
*
* For Kepler &tm; or newer fully supported devices.
*
* To just query the number of processes ready to be queried, call this function with *count = 0 and
* pids=NULL. The return code will be NVML_ERROR_INSUFFICIENT_SIZE, or NVML_SUCCESS if list is empty.
*
* For more details see \ref nvmlDeviceGetAccountingStats.
*
* @note In case of PID collision some processes might not be accessible before the circular buffer is full.
*
* @param device The identifier of the target device
* @param count Reference in which to provide the \a pids array size, and
* to return the number of elements ready to be queried
* @param pids Reference in which to return list of process ids
*
* @return
* - \ref NVML_SUCCESS if pids were successfully retrieved
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a count is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature or accounting mode is disabled
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a count is too small (\a count is set to
* expected value)
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetAccountingBufferSize
*/
nvmlReturn_t DECLDIR nvmlDeviceGetAccountingPids(nvmlDevice_t device, unsigned int *count, unsigned int *pids);
/**
* Returns the number of processes that the circular buffer with accounting pids can hold.
*
* For Kepler &tm; or newer fully supported devices.
*
* This is the maximum number of processes that accounting information will be stored for before information
* about oldest processes will get overwritten by information about new processes.
*
* @param device The identifier of the target device
* @param bufferSize Reference in which to provide the size (in number of elements)
* of the circular buffer for accounting stats.
*
* @return
* - \ref NVML_SUCCESS if buffer size was successfully retrieved
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a bufferSize is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature or accounting mode is disabled
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetAccountingStats
* @see nvmlDeviceGetAccountingPids
*/
nvmlReturn_t DECLDIR nvmlDeviceGetAccountingBufferSize(nvmlDevice_t device, unsigned int *bufferSize);
/** @} */
/** @addtogroup nvmlDeviceQueries
* @{
*/
/**
* Returns the list of retired pages by source, including pages that are pending retirement
* The address information provided from this API is the hardware address of the page that was retired. Note
* that this does not match the virtual address used in CUDA, but will match the address information in XID 63
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param cause Filter page addresses by cause of retirement
* @param pageCount Reference in which to provide the \a addresses buffer size, and
* to return the number of retired pages that match \a cause
* Set to 0 to query the size without allocating an \a addresses buffer
* @param addresses Buffer to write the page addresses into
*
* @return
* - \ref NVML_SUCCESS if \a pageCount was populated and \a addresses was filled
* - \ref NVML_ERROR_INSUFFICIENT_SIZE if \a pageCount indicates the buffer is not large enough to store all the
* matching page addresses. \a pageCount is set to the needed size.
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid, \a pageCount is NULL, \a cause is invalid, or
* \a addresses is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetRetiredPages(nvmlDevice_t device, nvmlPageRetirementCause_t cause,
unsigned int *pageCount, unsigned long long *addresses);
/**
* Check if any pages are pending retirement and need a reboot to fully retire.
*
* For Kepler &tm; or newer fully supported devices.
*
* @param device The identifier of the target device
* @param isPending Reference in which to return the pending status
*
* @return
* - \ref NVML_SUCCESS if \a isPending was populated
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a isPending is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceGetRetiredPagesPendingStatus(nvmlDevice_t device, nvmlEnableState_t *isPending);
/** @} */
/***************************************************************************************************/
/** @defgroup nvmlUnitCommands Unit Commands
* This chapter describes NVML operations that change the state of the unit. For S-class products.
* Each of these requires root/admin access. Non-admin users will see an NVML_ERROR_NO_PERMISSION
* error code when invoking any of these methods.
* @{
*/
/***************************************************************************************************/
/**
* Set the LED state for the unit. The LED can be either green (0) or amber (1).
*
* For S-class products.
* Requires root/admin permissions.
*
* This operation takes effect immediately.
*
*
* Current S-Class products don't provide unique LEDs for each unit. As such, both front
* and back LEDs will be toggled in unison regardless of which unit is specified with this command.
*
* See \ref nvmlLedColor_t for available colors.
*
* @param unit The identifier of the target unit
* @param color The target LED color
*
* @return
* - \ref NVML_SUCCESS if the LED color has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a unit or \a color is invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if this is not an S-class product
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlUnitGetLedState()
*/
nvmlReturn_t DECLDIR nvmlUnitSetLedState(nvmlUnit_t unit, nvmlLedColor_t color);
/** @} */
/***************************************************************************************************/
/** @defgroup nvmlDeviceCommands Device Commands
* This chapter describes NVML operations that change the state of the device.
* Each of these requires root/admin access. Non-admin users will see an NVML_ERROR_NO_PERMISSION
* error code when invoking any of these methods.
* @{
*/
/***************************************************************************************************/
/**
* Set the persistence mode for the device.
*
* For all products.
* For Linux only.
* Requires root/admin permissions.
*
* The persistence mode determines whether the GPU driver software is torn down after the last client
* exits.
*
* This operation takes effect immediately. It is not persistent across reboots. After each reboot the
* persistence mode is reset to "Disabled".
*
* See \ref nvmlEnableState_t for available modes.
*
* @param device The identifier of the target device
* @param mode The target persistence mode
*
* @return
* - \ref NVML_SUCCESS if the persistence mode was set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a mode is invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetPersistenceMode()
*/
nvmlReturn_t DECLDIR nvmlDeviceSetPersistenceMode(nvmlDevice_t device, nvmlEnableState_t mode);
/**
* Set the compute mode for the device.
*
* For all products.
* Requires root/admin permissions.
*
* The compute mode determines whether a GPU can be used for compute operations and whether it can
* be shared across contexts.
*
* This operation takes effect immediately. Under Linux it is not persistent across reboots and
* always resets to "Default". Under windows it is persistent.
*
* Under windows compute mode may only be set to DEFAULT when running in WDDM
*
* See \ref nvmlComputeMode_t for details on available compute modes.
*
* @param device The identifier of the target device
* @param mode The target compute mode
*
* @return
* - \ref NVML_SUCCESS if the compute mode was set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a mode is invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetComputeMode()
*/
nvmlReturn_t DECLDIR nvmlDeviceSetComputeMode(nvmlDevice_t device, nvmlComputeMode_t mode);
/**
* Set the ECC mode for the device.
*
* For Kepler &tm; or newer fully supported devices.
* Only applicable to devices with ECC.
* Requires \a NVML_INFOROM_ECC version 1.0 or higher.
* Requires root/admin permissions.
*
* The ECC mode determines whether the GPU enables its ECC support.
*
* This operation takes effect after the next reboot.
*
* See \ref nvmlEnableState_t for details on available modes.
*
* @param device The identifier of the target device
* @param ecc The target ECC mode
*
* @return
* - \ref NVML_SUCCESS if the ECC mode was set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a ecc is invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetEccMode()
*/
nvmlReturn_t DECLDIR nvmlDeviceSetEccMode(nvmlDevice_t device, nvmlEnableState_t ecc);
/**
* Clear the ECC error and other memory error counts for the device.
*
* For Kepler &tm; or newer fully supported devices.
* Only applicable to devices with ECC.
* Requires \a NVML_INFOROM_ECC version 2.0 or higher to clear aggregate location-based ECC counts.
* Requires \a NVML_INFOROM_ECC version 1.0 or higher to clear all other ECC counts.
* Requires root/admin permissions.
* Requires ECC Mode to be enabled.
*
* Sets all of the specified ECC counters to 0, including both detailed and total counts.
*
* This operation takes effect immediately.
*
* See \ref nvmlMemoryErrorType_t for details on available counter types.
*
* @param device The identifier of the target device
* @param counterType Flag that indicates which type of errors should be cleared.
*
* @return
* - \ref NVML_SUCCESS if the error counts were cleared
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a counterType is invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see
* - nvmlDeviceGetDetailedEccErrors()
* - nvmlDeviceGetTotalEccErrors()
*/
nvmlReturn_t DECLDIR nvmlDeviceClearEccErrorCounts(nvmlDevice_t device, nvmlEccCounterType_t counterType);
/**
* Set the driver model for the device.
*
* For Fermi &tm; or newer fully supported devices.
* For windows only.
* Requires root/admin permissions.
*
* On Windows platforms the device driver can run in either WDDM or WDM (TCC) mode. If a display is attached
* to the device it must run in WDDM mode.
*
* It is possible to force the change to WDM (TCC) while the display is still attached with a force flag (nvmlFlagForce).
* This should only be done if the host is subsequently powered down and the display is detached from the device
* before the next reboot.
*
* This operation takes effect after the next reboot.
*
* Windows driver model may only be set to WDDM when running in DEFAULT compute mode.
*
* Change driver model to WDDM is not supported when GPU doesn't support graphics acceleration or
* will not support it after reboot. See \ref nvmlDeviceSetGpuOperationMode.
*
* See \ref nvmlDriverModel_t for details on available driver models.
* See \ref nvmlFlagDefault and \ref nvmlFlagForce
*
* @param device The identifier of the target device
* @param driverModel The target driver model
* @param flags Flags that change the default behavior
*
* @return
* - \ref NVML_SUCCESS if the driver model has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a driverModel is invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the platform is not windows or the device does not support this feature
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetDriverModel()
*/
nvmlReturn_t DECLDIR nvmlDeviceSetDriverModel(nvmlDevice_t device, nvmlDriverModel_t driverModel, unsigned int flags);
/**
* Set clocks that applications will lock to.
*
* Sets the clocks that compute and graphics applications will be running at.
* e.g. CUDA driver requests these clocks during context creation which means this property
* defines clocks at which CUDA applications will be running unless some overspec event
* occurs (e.g. over power, over thermal or external HW brake).
*
* Can be used as a setting to request constant performance.
*
* For Kepler &tm; or newer non-GeForce fully supported devices and Maxwell or newer GeForce devices.
* Requires root/admin permissions.
*
* See \ref nvmlDeviceGetSupportedMemoryClocks and \ref nvmlDeviceGetSupportedGraphicsClocks
* for details on how to list available clocks combinations.
*
* After system reboot or driver reload applications clocks go back to their default value.
* See \ref nvmlDeviceResetApplicationsClocks.
*
* @param device The identifier of the target device
* @param memClockMHz Requested memory clock in MHz
* @param graphicsClockMHz Requested graphics clock in MHz
*
* @return
* - \ref NVML_SUCCESS if new settings were successfully set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a memClockMHz and \a graphicsClockMHz
* is not a valid clock combination
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
* - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceSetApplicationsClocks(nvmlDevice_t device, unsigned int memClockMHz, unsigned int graphicsClockMHz);
/**
* Set new power limit of this device.
*
* For Kepler &tm; or newer fully supported devices.
* Requires root/admin permissions.
*
* See \ref nvmlDeviceGetPowerManagementLimitConstraints to check the allowed ranges of values.
*
* \note Limit is not persistent across reboots or driver unloads.
* Enable persistent mode to prevent driver from unloading when no application is using the device.
*
* @param device The identifier of the target device
* @param limit Power management limit in milliwatts to set
*
* @return
* - \ref NVML_SUCCESS if \a limit has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a defaultLimit is out of range
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support this feature
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceGetPowerManagementLimitConstraints
* @see nvmlDeviceGetPowerManagementDefaultLimit
*/
nvmlReturn_t DECLDIR nvmlDeviceSetPowerManagementLimit(nvmlDevice_t device, unsigned int limit);
/**
* Sets new GOM. See \a nvmlGpuOperationMode_t for details.
*
* For GK110 M-class and X-class Tesla &tm; products from the Kepler family.
* Modes \ref NVML_GOM_LOW_DP and \ref NVML_GOM_ALL_ON are supported on fully supported GeForce products.
* Not supported on Quadro ® and Tesla &tm; C-class products.
* Requires root/admin permissions.
*
* Changing GOMs requires a reboot.
* The reboot requirement might be removed in the future.
*
* Compute only GOMs don't support graphics acceleration. Under windows switching to these GOMs when
* pending driver model is WDDM is not supported. See \ref nvmlDeviceSetDriverModel.
*
* @param device The identifier of the target device
* @param mode Target GOM
*
* @return
* - \ref NVML_SUCCESS if \a mode has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a mode incorrect
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support GOM or specific mode
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlGpuOperationMode_t
* @see nvmlDeviceGetGpuOperationMode
*/
nvmlReturn_t DECLDIR nvmlDeviceSetGpuOperationMode(nvmlDevice_t device, nvmlGpuOperationMode_t mode);
/**
* Changes the root/admin restructions on certain APIs. See \a nvmlRestrictedAPI_t for the list of supported APIs.
* This method can be used by a root/admin user to give non-root/admin access to certain otherwise-restricted APIs.
* The new setting lasts for the lifetime of the NVIDIA driver; it is not persistent. See \a nvmlDeviceGetAPIRestriction
* to query the current restriction settings.
*
* For Kepler &tm; or newer fully supported devices.
* Requires root/admin permissions.
*
* @param device The identifier of the target device
* @param apiType Target API type for this operation
* @param isRestricted The target restriction
*
* @return
* - \ref NVML_SUCCESS if \a isRestricted has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device is invalid or \a apiType incorrect
* - \ref NVML_ERROR_NOT_SUPPORTED if the device does not support changing API restrictions or the device does not support
* the feature that api restrictions are being set for (E.G. Enabling/disabling auto
* boosted clocks is not supported by the device)
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlRestrictedAPI_t
*/
nvmlReturn_t DECLDIR nvmlDeviceSetAPIRestriction(nvmlDevice_t device, nvmlRestrictedAPI_t apiType, nvmlEnableState_t isRestricted);
/**
* @}
*/
/** @addtogroup nvmlAccountingStats
* @{
*/
/**
* Enables or disables per process accounting.
*
* For Kepler &tm; or newer fully supported devices.
* Requires root/admin permissions.
*
* @note This setting is not persistent and will default to disabled after driver unloads.
* Enable persistence mode to be sure the setting doesn't switch off to disabled.
*
* @note Enabling accounting mode has no negative impact on the GPU performance.
*
* @note Disabling accounting clears all accounting pids information.
*
* See \ref nvmlDeviceGetAccountingMode
* See \ref nvmlDeviceGetAccountingStats
* See \ref nvmlDeviceClearAccountingPids
*
* @param device The identifier of the target device
* @param mode The target accounting mode
*
* @return
* - \ref NVML_SUCCESS if the new mode has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device or \a mode are invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceSetAccountingMode(nvmlDevice_t device, nvmlEnableState_t mode);
/**
* Clears accounting information about all processes that have already terminated.
*
* For Kepler &tm; or newer fully supported devices.
* Requires root/admin permissions.
*
* See \ref nvmlDeviceGetAccountingMode
* See \ref nvmlDeviceGetAccountingStats
* See \ref nvmlDeviceSetAccountingMode
*
* @param device The identifier of the target device
*
* @return
* - \ref NVML_SUCCESS if accounting information has been cleared
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a device are invalid
* - \ref NVML_ERROR_NOT_SUPPORTED if the device doesn't support this feature
* - \ref NVML_ERROR_NO_PERMISSION if the user doesn't have permission to perform this operation
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*/
nvmlReturn_t DECLDIR nvmlDeviceClearAccountingPids(nvmlDevice_t device);
/** @} */
/***************************************************************************************************/
/** @defgroup nvmlEvents Event Handling Methods
* This chapter describes methods that NVML can perform against each device to register and wait for
* some event to occur.
* @{
*/
/***************************************************************************************************/
/**
* Create an empty set of events.
* Event set should be freed by \ref nvmlEventSetFree
*
* For Fermi &tm; or newer fully supported devices.
* @param set Reference in which to return the event handle
*
* @return
* - \ref NVML_SUCCESS if the event has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a set is NULL
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlEventSetFree
*/
nvmlReturn_t DECLDIR nvmlEventSetCreate(nvmlEventSet_t *set);
/**
* Starts recording of events on a specified devices and add the events to specified \ref nvmlEventSet_t
*
* For Fermi &tm; or newer fully supported devices.
* Ecc events are available only on ECC enabled devices (see \ref nvmlDeviceGetTotalEccErrors)
* Power capping events are available only on Power Management enabled devices (see \ref nvmlDeviceGetPowerManagementMode)
*
* For Linux only.
*
* \b IMPORTANT: Operations on \a set are not thread safe
*
* This call starts recording of events on specific device.
* All events that occurred before this call are not recorded.
* Checking if some event occurred can be done with \ref nvmlEventSetWait
*
* If function reports NVML_ERROR_UNKNOWN, event set is in undefined state and should be freed.
* If function reports NVML_ERROR_NOT_SUPPORTED, event set can still be used. None of the requested eventTypes
* are registered in that case.
*
* @param device The identifier of the target device
* @param eventTypes Bitmask of \ref nvmlEventType to record
* @param set Set to which add new event types
*
* @return
* - \ref NVML_SUCCESS if the event has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a eventTypes is invalid or \a set is NULL
* - \ref NVML_ERROR_NOT_SUPPORTED if the platform does not support this feature or some of requested event types
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlEventType
* @see nvmlDeviceGetSupportedEventTypes
* @see nvmlEventSetWait
* @see nvmlEventSetFree
*/
nvmlReturn_t DECLDIR nvmlDeviceRegisterEvents(nvmlDevice_t device, unsigned long long eventTypes, nvmlEventSet_t set);
/**
* Returns information about events supported on device
*
* For Fermi &tm; or newer fully supported devices.
*
* Events are not supported on Windows. So this function returns an empty mask in \a eventTypes on Windows.
*
* @param device The identifier of the target device
* @param eventTypes Reference in which to return bitmask of supported events
*
* @return
* - \ref NVML_SUCCESS if the eventTypes has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a eventType is NULL
* - \ref NVML_ERROR_GPU_IS_LOST if the target GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlEventType
* @see nvmlDeviceRegisterEvents
*/
nvmlReturn_t DECLDIR nvmlDeviceGetSupportedEventTypes(nvmlDevice_t device, unsigned long long *eventTypes);
/**
* Waits on events and delivers events
*
* For Fermi &tm; or newer fully supported devices.
*
* If some events are ready to be delivered at the time of the call, function returns immediately.
* If there are no events ready to be delivered, function sleeps till event arrives
* but not longer than specified timeout. This function in certain conditions can return before
* specified timeout passes (e.g. when interrupt arrives)
*
* In case of xid error, the function returns the most recent xid error type seen by the system. If there are multiple
* xid errors generated before nvmlEventSetWait is invoked then the last seen xid error type is returned for all
* xid error events.
*
* @param set Reference to set of events to wait on
* @param data Reference in which to return event data
* @param timeoutms Maximum amount of wait time in milliseconds for registered event
*
* @return
* - \ref NVML_SUCCESS if the data has been set
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_INVALID_ARGUMENT if \a data is NULL
* - \ref NVML_ERROR_TIMEOUT if no event arrived in specified timeout or interrupt arrived
* - \ref NVML_ERROR_GPU_IS_LOST if a GPU has fallen off the bus or is otherwise inaccessible
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlEventType
* @see nvmlDeviceRegisterEvents
*/
nvmlReturn_t DECLDIR nvmlEventSetWait(nvmlEventSet_t set, nvmlEventData_t * data, unsigned int timeoutms);
/**
* Releases events in the set
*
* For Fermi &tm; or newer fully supported devices.
*
* @param set Reference to events to be released
*
* @return
* - \ref NVML_SUCCESS if the event has been successfully released
* - \ref NVML_ERROR_UNINITIALIZED if the library has not been successfully initialized
* - \ref NVML_ERROR_UNKNOWN on any unexpected error
*
* @see nvmlDeviceRegisterEvents
*/
nvmlReturn_t DECLDIR nvmlEventSetFree(nvmlEventSet_t set);
/** @} */
/**
* NVML API versioning support
*/
#if defined(__NVML_API_VERSION_INTERNAL)
#undef nvmlDeviceGetPciInfo
#undef nvmlDeviceGetCount
#undef nvmlDeviceGetHandleByIndex
#undef nvmlDeviceGetHandleByPciBusId
#undef nvmlInit
#endif
#ifdef __cplusplus
}
#endif
#endif
thinkfan-1.3.1/rcscripts/ 0000775 0000000 0000000 00000000000 14177511724 0015343 5 ustar 00root root 0000000 0000000 thinkfan-1.3.1/rcscripts/openrc/ 0000775 0000000 0000000 00000000000 14177511724 0016631 5 ustar 00root root 0000000 0000000 thinkfan-1.3.1/rcscripts/openrc/thinkfan.cmake 0000664 0000000 0000000 00000000524 14177511724 0021436 0 ustar 00root root 0000000 0000000 #!/sbin/openrc-run
command="@CMAKE_INSTALL_PREFIX@/sbin/thinkfan"
command_args="-q -s5 -c /etc/thinkfan.conf"
pidfile="@PID_FILE@"
extra_started_commands="reload"
required_files="/etc/thinkfan.conf"
depend() {
after modules
}
reload() {
ebegin "Reloading ${SVCNAME}"
start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
}
thinkfan-1.3.1/rcscripts/systemd/ 0000775 0000000 0000000 00000000000 14177511724 0017033 5 ustar 00root root 0000000 0000000 thinkfan-1.3.1/rcscripts/systemd/override.conf 0000664 0000000 0000000 00000000270 14177511724 0021520 0 ustar 00root root 0000000 0000000 [Service]
# Decrease biasing (up to -b-10) if your fan speed changes too quickly,
# Increase biasing (up to -b20) if your fan speed changes too slowly.
Environment='THINKFAN_ARGS=-b0'
thinkfan-1.3.1/rcscripts/systemd/thinkfan-sleep.service 0000664 0000000 0000000 00000000427 14177511724 0023330 0 ustar 00root root 0000000 0000000 [Unit]
Description=Notify thinkfan of imminent sleep
Before=sleep.target
[Service]
Type=oneshot
ExecStart=/usr/bin/pkill -x -winch thinkfan
# Hack: Since the signal handler races with the sleep, we need to delay a bit
ExecStart=/usr/bin/sleep 1
[Install]
WantedBy=sleep.target
thinkfan-1.3.1/rcscripts/systemd/thinkfan-wakeup.service 0000664 0000000 0000000 00000000443 14177511724 0023512 0 ustar 00root root 0000000 0000000 [Unit]
Description=Reload thinkfan after waking up from suspend
After=sysinit.target
After=suspend.target
After=suspend-then-hibernate.target
After=hybrid-sleep.target
After=hibernate.target
[Service]
Type=oneshot
ExecStart=/usr/bin/pkill -x -usr2 thinkfan
[Install]
WantedBy=sleep.target
thinkfan-1.3.1/rcscripts/systemd/thinkfan.service.cmake 0000664 0000000 0000000 00000000531 14177511724 0023275 0 ustar 00root root 0000000 0000000 [Unit]
Description=thinkfan @THINKFAN_VERSION@
After=sysinit.target
After=systemd-modules-load.service
[Service]
Type=forking
ExecStart=@CMAKE_INSTALL_PREFIX@/sbin/thinkfan $THINKFAN_ARGS
PIDFile=/run/thinkfan.pid
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
Also=thinkfan-sleep.service
Also=thinkfan-wakeup.service
thinkfan-1.3.1/rcscripts/sysvinit/ 0000775 0000000 0000000 00000000000 14177511724 0017233 5 ustar 00root root 0000000 0000000 thinkfan-1.3.1/rcscripts/sysvinit/thinkfan.default 0000664 0000000 0000000 00000000442 14177511724 0022403 0 ustar 00root root 0000000 0000000 # Should thinkfan be started automatically on boot?
# Only say "yes" when you know what you are doing, have configured
# thinkfan correctly for *YOUR* machine and loaded thinkpad_acpi
# with fan_control=1 (if you have a ThinkPad).
START=no
# Additional startup parameters
DAEMON_ARGS="-q"
thinkfan-1.3.1/rcscripts/sysvinit/thinkfan.init 0000664 0000000 0000000 00000007605 14177511724 0021732 0 ustar 00root root 0000000 0000000 #! /bin/sh
### BEGIN INIT INFO
# Provides: thinkfan
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: thinkfan initscript
# Description: starts thinkfan if enabled in /etc/default/thinkfan
### END INIT INFO
# Author: Evgeni Golov
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="fan control tool"
NAME=thinkfan
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS="-q"
# This one is compiled-in, you can't change it here!
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
START=no
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Check if daemon is to be started
[ "$START" = "yes" ] || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
reload|force-reload)
log_daemon_msg "Reloading $DESC" "$NAME"
do_reload
log_end_msg $?
;;
restart)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|restart|status|restart|force-reload}" >&2
exit 3
;;
esac
:
thinkfan-1.3.1/src/ 0000775 0000000 0000000 00000000000 14177511724 0014116 5 ustar 00root root 0000000 0000000 thinkfan-1.3.1/src/config.cpp 0000664 0000000 0000000 00000026257 14177511724 0016103 0 ustar 00root root 0000000 0000000 /********************************************************************
* config.cpp: Config data structures and consistency checking.
* (C) 2015, Victor Mataré
*
* this file is part of thinkfan. See thinkfan.c for further information.
*
* thinkfan is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* thinkfan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with thinkfan. If not, see .
*
* ******************************************************************/
#include "config.h"
#include
#include
#include
#include
#include
#include
#include "parser.h"
#include "message.h"
#include "thinkfan.h"
#ifdef USE_YAML
#include "yamlconfig.h"
#endif
namespace thinkfan {
FanConfig::FanConfig(unique_ptr &&fan_drv)
: fan_(std::move(fan_drv))
{}
const unique_ptr &FanConfig::fan() const
{ return fan_; }
void FanConfig::set_fan(unique_ptr &&fan)
{ fan_ = std::move(fan); }
StepwiseMapping::StepwiseMapping(unique_ptr &&fan_drv)
: FanConfig(std::move(fan_drv))
{}
const vector> &StepwiseMapping::levels() const
{ return levels_; }
void StepwiseMapping::init_fanspeed(const TemperatureState &ts)
{
cur_lvl_ = --levels().end();
while (cur_lvl_ != levels().begin() && (*cur_lvl_)->down(ts))
cur_lvl_--;
fan()->set_speed(**cur_lvl_);
}
bool StepwiseMapping::set_fanspeed(const TemperatureState &ts)
{
if (unlikely(cur_lvl_ != --levels().end() && (*cur_lvl_)->up(ts))) {
while (cur_lvl_ != --levels().end() && (*cur_lvl_)->up(ts))
cur_lvl_++;
fan()->set_speed(**cur_lvl_);
return true;
}
else if (unlikely(cur_lvl_ != levels().begin() && (*cur_lvl_)->down(ts))) {
while (cur_lvl_ != levels().begin() && (*cur_lvl_)->down(ts))
cur_lvl_--;
fan()->set_speed(**cur_lvl_);
tmp_sleeptime = sleeptime;
return true;
}
else {
fan()->ping_watchdog_and_depulse(**cur_lvl_);
return false;
}
}
void StepwiseMapping::ensure_consistency(const Config &config) const
{
if (levels().size() == 0)
throw ConfigError("No fan levels specified.");
if (!fan())
throw ConfigError("No fan specified in stepwise mapping.");
for (auto &lvl : levels())
lvl->ensure_consistency(config);
int maxlvl = (*levels_.rbegin())->num();
if (dynamic_cast(fan().get()) && maxlvl < 128)
error(MSG_CONF_MAXLVL((*levels_.rbegin())->num()));
else if (dynamic_cast(fan().get())
&& maxlvl != std::numeric_limits::max()
&& maxlvl > 7
&& maxlvl != 127)
error(MSG_CONF_TP_LVL7(maxlvl, 7));
}
void StepwiseMapping::add_level(unique_ptr &&level)
{
if (levels_.size() > 0) {
const unique_ptr &last_lvl = levels_.back();
if (level->num() != std::numeric_limits::max()
&& level->num() != std::numeric_limits::min()
&& last_lvl->num() > level->num())
error(MSG_CONF_LVLORDER);
if (last_lvl->upper_limit().size() != level->upper_limit().size())
error(MSG_CONF_LVLORDER);
for (vector::const_iterator mit = last_lvl->upper_limit().begin(), oit = level->lower_limit().begin();
mit != last_lvl->upper_limit().end() && oit != level->lower_limit().end();
++mit, ++oit)
{
if (*mit < *oit) error(MSG_CONF_OVERLAP);
}
}
levels_.push_back(std::move(level));
}
Config::Config()
: num_temps_(0)
{}
const Config *Config::read_config(const vector &filenames)
{
const Config *rv = nullptr;
for (auto it = filenames.begin(); it != filenames.end(); ++it) {
try {
rv = try_read_config(*it);
break;
} catch (IOerror &e) {
if (e.code() != ENOENT || it+1 >= filenames.end())
throw;
}
}
return rv;
}
const Config *Config::try_read_config(const string &filename)
{
Config *rv = nullptr;
ifstream f_in(filename);
if (!(f_in.is_open() && f_in.good()))
throw IOerror(filename + ": ", errno);
if (!f_in.seekg(0, f_in.end))
throw IOerror(filename + ": ", errno);
ifstream::pos_type f_size = f_in.tellg();
if (!f_in.seekg(0, f_in.beg))
throw IOerror(filename + ": ", errno);
string f_data;
f_data.resize(f_size, 0);
if (!f_in.read(&*f_data.begin(), f_size))
throw IOerror(filename + ": ", errno);
#ifdef USE_YAML
try {
YAML::Node root = YAML::Load(f_data);
// Copy the return value first. Workaround for https://github.com/vmatare/thinkfan/issues/42
// due to bug in ancient yaml-cpp: https://github.com/jbeder/yaml-cpp/commit/97d56c3f3608331baaee26e17d2f116d799a7edc
try {
YAML::wtf_ptr rv_tmp = root.as>();
rv = rv_tmp.release();
} catch (IOerror &e) {
// An IOerror while processing the config means that an invalid sensor or fan path was specified.
// That's a user error, wrap it and let it escalate.
throw ConfigError(e.what());
}
#if not defined(DISABLE_EXCEPTION_CATCHING)
} catch(YamlError &e) {
throw ConfigError(filename, e.mark, f_data, e.what());
} catch(YAML::RepresentationException &e) {
throw ConfigError(filename, e.mark, f_data, "Invalid entry");
#endif
} catch(YAML::ParserException &e) {
string::size_type ext_off = filename.rfind('.');
if (ext_off != string::npos) {
string ext = filename.substr(filename.rfind('.'));
std::for_each(ext.begin(), ext.end(), [] (char &c) {
c = std::toupper(c, std::locale());
} );
if (ext == ".YAML")
throw ConfigError(filename, e.mark, f_data, e.what());
}
#endif //USE_YAML
ConfigParser parser;
const char *input = f_data.c_str();
const char *start = input;
rv = parser.parse_config(input);
if (!rv) {
throw SyntaxError(filename, parser.get_max_addr() - start, f_data);
}
#ifdef USE_YAML
}
#endif //USE_YAML
rv->src_file = filename;
rv->ensure_consistency();
return rv;
}
void Config::ensure_consistency() const
{
// Consistency checks which require the complete config
if (fan_configs().empty())
throw ConfigError("No fans are configured in " + src_file);
for (const unique_ptr &fan_cfg : fan_configs())
try {
fan_cfg->ensure_consistency(*this);
} catch (ConfigError &err) {
err.set_filename(src_file);
throw;
}
if (sensors().size() < 1)
throw ConfigError(src_file + ": " + MSG_NO_SENSOR);
}
void Config::add_sensor(unique_ptr &&sensor)
{
num_temps_ += sensor->num_temps();
sensors_.push_back(std::move(sensor));
}
unsigned int Config::num_temps() const
{ return num_temps_; }
const vector> &Config::sensors() const
{ return sensors_; }
const vector> &Config::fan_configs() const
{ return temp_mappings_; }
void Config::add_fan_config(unique_ptr &&fan_cfg)
{ temp_mappings_.push_back(std::move(fan_cfg)); }
void Config::init_fans() const
{
for (const unique_ptr &fan_cfg : fan_configs())
fan_cfg->fan()->init();
}
Level::Level(int level, int lower_limit, int upper_limit)
: Level(level, vector(1, lower_limit), vector(1, upper_limit))
{}
Level::Level(string level, int lower_limit, int upper_limit)
: Level(level, vector(1, lower_limit), vector(1, upper_limit))
{}
Level::Level(int level, const vector &lower_limit, const vector &upper_limit)
: level_s_("level " + std::to_string(level)),
level_n_(level),
lower_limit_(lower_limit),
upper_limit_(upper_limit)
{}
Level::Level(string level, const vector &lower_limit, const vector &upper_limit)
: level_s_(level),
level_n_(string_to_int(level_s_)),
lower_limit_(lower_limit),
upper_limit_(upper_limit)
{
if (lower_limit.size() != upper_limit.size())
error(MSG_CONF_LIMITLEN);
for (vector::const_iterator l_it = lower_limit.begin(), u_it = upper_limit.begin();
l_it != lower_limit.end() && u_it != upper_limit.end();
++u_it, ++l_it) {
if (*l_it != numeric_limits::max() && *l_it >= *u_it)
error(MSG_CONF_LOWHIGH);
}
}
int Level::string_to_int(string &level) {
int rv;
if (level == "level auto" || level == "level disengaged" || level == "level full-speed")
return std::numeric_limits::min();
else if (sscanf(level.c_str(), "level %d", &rv) == 1)
return rv;
else try {
rv = std::stoi(level);
level = "level " + level;
} catch (std::out_of_range &) {
error(MSG_CONF_LVLFORMAT(level));
} catch (std::invalid_argument &) {
error(MSG_CONF_LVLFORMAT(level));
}
return rv;
}
const vector &Level::lower_limit() const
{ return lower_limit_; }
const vector &Level::upper_limit() const
{ return upper_limit_; }
const string &Level::str() const
{ return this->level_s_; }
int Level::num() const
{ return this->level_n_; }
SimpleLevel::SimpleLevel(int level, int lower_limit, int upper_limit)
: Level(level, lower_limit, upper_limit)
{}
SimpleLevel::SimpleLevel(string level, int lower_limit, int upper_limit)
: Level(level, lower_limit, upper_limit)
{}
bool SimpleLevel::up(const TemperatureState &temp_state) const
{ return *temp_state.tmax >= upper_limit().front(); }
bool SimpleLevel::down(const TemperatureState &temp_state) const
{ return *temp_state.tmax < lower_limit().front(); }
void SimpleLevel::ensure_consistency(const Config &) const
{}
ComplexLevel::ComplexLevel(int level, const vector &lower_limit, const vector &upper_limit)
: Level(level, lower_limit, upper_limit)
{}
ComplexLevel::ComplexLevel(string level, const vector &lower_limit, const vector &upper_limit)
: Level(level, lower_limit, upper_limit)
{}
bool ComplexLevel::up(const TemperatureState &temp_state) const
{
vector::const_iterator temp_it = temp_state.biased_temps().begin();
auto upper_it = upper_limit().begin();
while (temp_it != temp_state.biased_temps().end())
if (*temp_it++ >= *upper_it++) return true;
return false;
}
bool ComplexLevel::down(const TemperatureState &temp_state) const
{
auto temp_it = temp_state.biased_temps().begin();
auto lower_it = lower_limit().begin();
while (temp_it != temp_state.biased_temps().end() && *temp_it < *lower_it) {
temp_it++;
lower_it++;
}
return temp_it == temp_state.biased_temps().end();
}
void ComplexLevel::ensure_consistency(const Config &cfg) const
{
string limitstr;
const string restmsg = " must have the length "
+ std::to_string(cfg.num_temps())
+ " (one entry for each configured sensor)"
;
if (lower_limit().size() != cfg.num_temps())
throw ConfigError(
"Lower limit "
+ format_limit(lower_limit())
+ restmsg
);
if (upper_limit().size() != cfg.num_temps())
throw ConfigError(
"Upper limit "
+ format_limit(upper_limit())
+ restmsg
);
}
string ComplexLevel::format_limit(const vector &limit)
{
return "[" + std::accumulate(
std::next(limit.begin()),
limit.end(),
std::to_string(limit.front()),
[] (string l, int r) -> string {
return std::move(l) + ", " + std::to_string(r);
}
) + "]";
}
} /* namespace thinkfan */
thinkfan-1.3.1/src/config.h 0000664 0000000 0000000 00000011076 14177511724 0015541 0 ustar 00root root 0000000 0000000 /********************************************************************
* config.h: Config data structures and consistency checking.
* (C) 2015, Victor Mataré
*
* this file is part of thinkfan. See thinkfan.c for further information.
*
* thinkfan is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* thinkfan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with thinkfan. If not, see .
*
* ******************************************************************/
#ifndef THINKFAN_CONFIG_H_
#define THINKFAN_CONFIG_H_
#include "error.h"
#include
#include
#include
#include