util_system.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2011-2013 Blender Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef __UTIL_SYSTEM_H__
  17. #define __UTIL_SYSTEM_H__
  18. #include "util/util_string.h"
  19. #include "util/util_vector.h"
  20. CCL_NAMESPACE_BEGIN
  21. /* Make sure CPU groups / NUMA API is initialized. */
  22. bool system_cpu_ensure_initialized();
  23. /* Get total number of threads in all NUMA nodes / CPU groups. */
  24. int system_cpu_thread_count();
  25. /* Get width in characters of the current console output. */
  26. int system_console_width();
  27. /* Get number of available nodes.
  28. *
  29. * This is in fact an index of last node plus one and it's not guaranteed
  30. * that all nodes up to this one are available. */
  31. int system_cpu_num_numa_nodes();
  32. /* Returns truth if the given node is available for compute. */
  33. bool system_cpu_is_numa_node_available(int node);
  34. /* Get number of available processors on a given node. */
  35. int system_cpu_num_numa_node_processors(int node);
  36. /* Runs the current thread and its children on a specific node.
  37. *
  38. * Returns truth if affinity has successfully changed. */
  39. bool system_cpu_run_thread_on_node(int node);
  40. /* Number of processors within the current CPU group (or within active thread
  41. * thread affinity). */
  42. int system_cpu_num_active_group_processors();
  43. string system_cpu_brand_string();
  44. int system_cpu_bits();
  45. bool system_cpu_support_sse2();
  46. bool system_cpu_support_sse3();
  47. bool system_cpu_support_sse41();
  48. bool system_cpu_support_avx();
  49. bool system_cpu_support_avx2();
  50. size_t system_physical_ram();
  51. /* Start a new process of the current application with the given arguments. */
  52. bool system_call_self(const vector<string> &args);
  53. CCL_NAMESPACE_END
  54. #endif /* __UTIL_SYSTEM_H__ */