initial commit
This commit is contained in:
50
examples/CMakeLists.txt
Normal file
50
examples/CMakeLists.txt
Normal file
@@ -0,0 +1,50 @@
|
||||
# removed -Wredundant-decls for cuda 10.1
|
||||
# removed -Wundef for cuda 10.0
|
||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} \
|
||||
-Xcompiler=-Wall\
|
||||
-Xcompiler=-Wextra\
|
||||
-Xcompiler=-Wcast-qual \
|
||||
-Xcompiler=-Wcast-align \
|
||||
-Xcompiler=-Wstrict-aliasing \
|
||||
-Xcompiler=-Wpointer-arith \
|
||||
-Xcompiler=-Winit-self \
|
||||
-Xcompiler=-Wshadow \
|
||||
-Xcompiler=-Wswitch-enum \
|
||||
-Xcompiler=-Wfloat-equal \
|
||||
-Xcompiler=-Wvla\
|
||||
-Xcompiler=-fmax-errors=1 \
|
||||
-Xcompiler=-Wfatal-errors\
|
||||
")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
|
||||
-Wredundant-decls \
|
||||
-Wundef \
|
||||
-Wall\
|
||||
-Wextra\
|
||||
-Wcast-qual \
|
||||
-Wcast-align \
|
||||
-Wstrict-aliasing \
|
||||
-Wpointer-arith \
|
||||
-Winit-self \
|
||||
-Wshadow \
|
||||
-Wswitch-enum \
|
||||
-Wfloat-equal \
|
||||
-Wvla\
|
||||
-fmax-errors=1 \
|
||||
-Wfatal-errors\
|
||||
")
|
||||
|
||||
add_executable(cpu-cache cpu_cache.cpp)
|
||||
target_link_libraries(cpu-cache perfect)
|
||||
|
||||
add_executable(cpu-turbo cpu_turbo.cpp)
|
||||
target_link_libraries(cpu-turbo perfect)
|
||||
|
||||
add_executable(os-perf os_perf.cpp)
|
||||
target_link_libraries(os-perf perfect)
|
||||
|
||||
add_executable(gpu-clocks gpu_clocks.cu)
|
||||
target_link_libraries(gpu-clocks perfect)
|
||||
|
||||
add_executable(gpu-turbo gpu_turbo.cu)
|
||||
target_link_libraries(gpu-turbo perfect)
|
11
examples/cpu_cache.cpp
Normal file
11
examples/cpu_cache.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "perfect/cpu_cache.hpp"
|
||||
|
||||
int main(void) {
|
||||
int *a = new int[1024];
|
||||
flush_all(a, 1024 * sizeof(int));
|
||||
|
||||
// do things with `a` flushed from cache into main memory
|
||||
// furthermore, all loads and stores before this function call are guaranteed to be complete
|
||||
|
||||
delete[] a;
|
||||
}
|
14
examples/cpu_turbo.cpp
Normal file
14
examples/cpu_turbo.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "perfect/cpu_turbo.hpp"
|
||||
|
||||
int main(void) {
|
||||
|
||||
perfect::CpuTurboState state;
|
||||
perfect::get_cpu_turbo_state(&state);
|
||||
|
||||
perfect::disable_cpu_turbo();
|
||||
|
||||
// do things with CPU turbo disabled
|
||||
|
||||
perfect::set_cpu_turbo_state(state);
|
||||
|
||||
}
|
5
examples/gpu_clocks.cu
Normal file
5
examples/gpu_clocks.cu
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "perfect/gpu_clocks.hpp"
|
||||
|
||||
int main(void) {
|
||||
|
||||
}
|
5
examples/gpu_turbo.cu
Normal file
5
examples/gpu_turbo.cu
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "perfect/gpu_turbo.hpp"
|
||||
|
||||
int main(void) {
|
||||
|
||||
}
|
26
examples/os_perf.cpp
Normal file
26
examples/os_perf.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "perfect/os_perf.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
int main(void) {
|
||||
|
||||
|
||||
std::map<int, perfect::OsPerfState> states;
|
||||
|
||||
for (auto cpu : perfect::cpus()) {
|
||||
perfect::OsPerfState state;
|
||||
perfect::get_os_perf_state(&state, cpu);
|
||||
states[cpu] = state;
|
||||
perfect::os_perf_state_maximum(cpu);
|
||||
}
|
||||
|
||||
// do things with all CPUs set to the maximum performancem mode by the OS
|
||||
|
||||
for (auto kv : states) {
|
||||
int cpu = kv.first;
|
||||
perfect::OsPerfState state = kv.second;
|
||||
perfect::set_os_perf_state(cpu, state);
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user