Commit aa08598c authored by artificiel's avatar artificiel
Browse files

Initial commit

parents
#########################
# general patterns
#########################
docs/html
docs/tagfile.xml
*/bin/*
!*/bin/data/
# for bin folder in root
/bin/*
!/bin/data/
[Bb]uild/
[Oo]bj/
*.o
[Dd]ebug*/
[Rr]elease*/
*.mode*
*.app/
*.pyc
.svn/
#########################
# IDE
#########################
# XCode
*.pbxuser
*.perspective
*.perspectivev3
*.mode1v3
*.mode2v3
#XCode 4
xcuserdata
*.xcworkspace
# Code::Blocks
*.depend
*.layout
*.cbTemp
# Visual Studio
*.sdf
*.opensdf
*.suo
*.pdb
*.ilk
*.aps
ipch/
# Eclipse
.metadata
local.properties
.externalToolBuilders
# Codelite
*.session
*.tags
*.workspace.*
#########################
# operating system
#########################
# Linux
*~
# KDE
.directory
.AppleDouble
# OSX
.DS_Store
*.swp
*~.nib
# Thumbnails
._*
# Windows
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
#Android
.csettings
#########################
# packages
#########################
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases
*.log
*.sql
*.sqlite
ofxNvidiaSmi
============
Introduction
------------
ofxNvidiaSmi ofSystem() calls the nvidia-smi utility and parses the result into a string-keyed std::map. This is handled in an async call to prevent hiccups during the ofSystem call.
Installation
------------
Basic addon; simply copy to the addons folder and #include "ofxNvidiaSmi.hpp".
Dependencies
------------
This addons depends on the presence of the nvidia-smi, which is part of the nvidia linux package.
TODO
----
1. Pre-parse some values as floats to help programmatic usage
Compatibility
-------------
Tested against the rolling versions in git between june and december 2019.
Version history
---------------
### Version 0.1 (2020-01-01):
Initial release.
License
-------
MIT License. (c) 2020 alexandre burton / artificiel.org. See License.md for additional information.
meta:
ADDON_NAME = ofxFboDeluxe
ADDON_DESCRIPTION = ofxFboDeluxe is an Fbo with color correction and histogram analysis
ADDON_AUTHOR = Alexandre Burton / artificiel.org
ADDON_TAGS = "addon" "fbo"
ADDON_URL = http://github.com/artificiel/ofxFboDeluxe
#This file is currently only for linux users!
#Add your addon and all other necessary ones here (without '#')
#put every addon in one line, for example
#myAddon
#ofxXmlSettings
#ofxOpenCv
#include "ofApp.h"
int main(){
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofSetupOpenGL(1024, 768, OF_WINDOW);
ofRunApp(new ofApp());
}
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
}
//--------------------------------------------------------------
void ofApp::update(){
}
//--------------------------------------------------------------
void ofApp::draw(){
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}
#pragma once
#include "ofMain.h"
#include "ofxAddonTemplate.h"
class ofApp: public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y);
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
};
The code in this repository is available under the [MIT License](https://secure.wikimedia.org/wikipedia/en/wiki/Mit_license).
Copyright (c) 2020 artificiel.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
#ifndef OFX_NVIDIA_SMI_HPP
#define OFX_NVIDIA_SMI_HPP
#include <future>
#include "ofMain.h"
#include "ofxXmlSettings.h"
class ofxNvidiaSmi {
public:
std::map<string, string> tags_;
ofxXmlSettings xml_;
pid_t my_pid_;
future<bool> async_smi_;
std::mutex mutex_;
ofxNvidiaSmi()
{
my_pid_ = getpid();
}
bool perform_in_bg()
{
std::map<string, string> tags;
xml_.loadFromBuffer(ofSystem("nvidia-smi -q -x"));
xml_.pushTag("nvidia_smi_log");
xml_.pushTag("gpu");
for (const auto& tag : { "product_name", "fan_speed",
"fb_memory_usage:total", "fb_memory_usage:used", "fb_memory_usage:free",
"utilization:gpu_util", "utilization:encoder_util", "utilization:decoder_util",
"temperature:gpu_temp", "temperature:gpu_temp_max_threshold", "temperature:gpu_temp_slow_threshold",
"power_readings:power_draw", "power_readings:power_limit" }) {
tags[tag] = xml_.getValue(tag, tag);
}
xml_.pushTag("processes");
int num_processes = xml_.getNumTags("process_info:pid");
for (int i = 0; i < num_processes; i++) {
int pid = ofToInt(xml_.getValue("process_info:pid", "0", i));
if (pid == my_pid_) {
tags["process_info:used_memory"] = xml_.getValue("process_info:used_memory", "", i);
}
}
mutex_.lock();
tags_ = tags;
mutex_.unlock();
return true;
}
void update()
{
if (async_smi_.valid()) {
if (async_smi_.wait_for(std::chrono::milliseconds(0)) != future_status::ready) {
ofLogNotice("import_image_sequence_to_buffer") << "busy";
return;
}
}
async_smi_ = async(launch::async, &ofxNvidiaSmi::perform_in_bg, this);
}
void draw(int x, int y)
{
ofPushMatrix();
ofTranslate(x, y + 20);
mutex_.lock();
ofDrawBitmapStringHighlight(tags_["utilization:gpu_util"] + " GPU; "
+ tags_["temperature:gpu_temp"]
+ " / " + tags_["temperature:gpu_temp_slow_threshold"]
+ " / " + tags_["temperature:gpu_temp_max_threshold"]
+ "; " + tags_["power_readings:power_draw"]
+ " / " + tags_["power_readings:power_limit"],
0, 0);
ofDrawBitmapStringHighlight(
"this = " + tags_["process_info:used_memory"]
+ "; all = " + tags_["fb_memory_usage:used"]
+ "; total = " + tags_["fb_memory_usage:total"]
+ " (free = " + tags_["fb_memory_usage:free"] + ")",
0, 20);
mutex_.unlock();
ofPopMatrix();
}
};
#endif // OFX_NVIDIA_SMI_HPP
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment