GCC Code Coverage Report


Directory: ./
File: build/TESTS/PERFORMANCE_TESTS/PERF_HADAMARD_PROXY_CMAKE/HadamardProductProxy/Hadamard_product_cmake_perfProxyLoader.cpp
Date: 2025-03-14 12:14:21
Exec Total Coverage
Lines: 0 61 0.0%
Branches: 0 100 0.0%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7
8 //Warning : this file has been generated automatically by the phoenix_hpc_proxy program
9 //You can find it at https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS/PhoenixHPCProxy
10 //Do NOT modify it
11
12
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <dlfcn.h>
16 #include <string.h>
17
18 #include "hadamard_product.h"
19
20 #include "Hadamard_product_cmake_perfProxyLoader.h"
21
22 ///Variable which will load automatically the right library by respect to the given architecture
23 Hadamard_product_cmake_perfProxyLoader PROXY_LOADER;
24
25 ///Default constructor of Hadamard_product_cmake_perfProxyLoader
26 Hadamard_product_cmake_perfProxyLoader::Hadamard_product_cmake_perfProxyLoader(){
27 initialisationHadamard_product_cmake_perfProxyLoader();
28 std::cout << "Hadamard_product_cmake_perfProxyLoader::Hadamard_product_cmake_perfProxyLoader() : check current architecture" << std::endl;
29 //First get the /proc/cpuinfo file
30 if(!parseArchFile("/proc/cpuinfo")){
31 //No library found, let's load the default library
32 load("libhadamard_product_cmake_perf_anyarch.so");
33 }
34 updateFunction();
35 }
36
37 ///Destructor of Hadamard_product_cmake_perfProxyLoader
38 Hadamard_product_cmake_perfProxyLoader::~Hadamard_product_cmake_perfProxyLoader(){
39 close();
40 }
41
42 ///Load the given library
43 /** @param libName : name of the library to be loaded
44 * @return true on success, false otherwise
45 */
46 bool Hadamard_product_cmake_perfProxyLoader::load(const std::string & libName){
47 if(libName == ""){return false;}
48 p_handle = dlopen(libName.c_str(), RTLD_LAZY);
49 std::cout << "Hadamard_product_cmake_perfProxyLoader::load : loading library '"<<libName<<"'" << std::endl;
50 if(p_handle == NULL){
51 fprintf(stderr, "Hadamard_product_cmake_perfProxyLoader::load : %s\n", dlerror());
52 return false;
53 }
54 dlerror(); //Erase an exsiting error
55 return true;
56 }
57
58 ///Parse the given architecture file
59 /** @param archfileName : name of the architecture file to be loaded
60 * @return true on success, false otherwise
61 */
62 bool Hadamard_product_cmake_perfProxyLoader::parseArchFile(const std::string & archfileName){
63 FILE * fp = fopen(archfileName.c_str(), "r");
64 if(fp == NULL){
65 std::cerr << "Cannot open file '" << archfileName << "'" << std::endl;
66 return false;
67 }
68 std::string bufferAllFile("");
69 int buffer;
70 while(!feof(fp)){
71 buffer = fgetc(fp);
72 if(buffer != EOF) bufferAllFile += (char)buffer;
73 else break;
74 }
75 if(bufferAllFile == ""){
76 std::cerr << "Empty file '" << archfileName << "'" << std::endl;
77 return false;
78 }
79 const char * procCpuInfo = bufferAllFile.c_str();
80 //Let's check the avalaible architectures
81 bool isLibFound(true);
82 if(strstr(procCpuInfo, "avx512f") != NULL){
83 load("/builds/CTA-LAPP/PHOENIX_LIBS2/PhoenixHPCProxy/build/TESTS/PERFORMANCE_TESTS/PERF_HADAMARD_PROXY_CMAKE/HadamardProductProxy/libhadamard_product_cmake_perf_avx512f.so");
84 }else if(strstr(procCpuInfo, "avx2") != NULL){
85 load("/builds/CTA-LAPP/PHOENIX_LIBS2/PhoenixHPCProxy/build/TESTS/PERFORMANCE_TESTS/PERF_HADAMARD_PROXY_CMAKE/HadamardProductProxy/libhadamard_product_cmake_perf_avx2.so");
86 }else if(strstr(procCpuInfo, "avx") != NULL){
87 load("/builds/CTA-LAPP/PHOENIX_LIBS2/PhoenixHPCProxy/build/TESTS/PERFORMANCE_TESTS/PERF_HADAMARD_PROXY_CMAKE/HadamardProductProxy/libhadamard_product_cmake_perf_avx.so");
88 }else if(strstr(procCpuInfo, "sse4.2") != NULL){
89 load("/builds/CTA-LAPP/PHOENIX_LIBS2/PhoenixHPCProxy/build/TESTS/PERFORMANCE_TESTS/PERF_HADAMARD_PROXY_CMAKE/HadamardProductProxy/libhadamard_product_cmake_perf_sse42.so");
90 }else if(strstr(procCpuInfo, "sse4.1") != NULL){
91 load("/builds/CTA-LAPP/PHOENIX_LIBS2/PhoenixHPCProxy/build/TESTS/PERFORMANCE_TESTS/PERF_HADAMARD_PROXY_CMAKE/HadamardProductProxy/libhadamard_product_cmake_perf_sse41.so");
92 }else if(strstr(procCpuInfo, "ssse3") != NULL){
93 load("/builds/CTA-LAPP/PHOENIX_LIBS2/PhoenixHPCProxy/build/TESTS/PERFORMANCE_TESTS/PERF_HADAMARD_PROXY_CMAKE/HadamardProductProxy/libhadamard_product_cmake_perf_ssse3.so");
94 }else if(strstr(procCpuInfo, "sse2") != NULL){
95 load("/builds/CTA-LAPP/PHOENIX_LIBS2/PhoenixHPCProxy/build/TESTS/PERFORMANCE_TESTS/PERF_HADAMARD_PROXY_CMAKE/HadamardProductProxy/libhadamard_product_cmake_perf_sse2.so");
96 }else if(strstr(procCpuInfo, "anyarch") != NULL){
97 load("/builds/CTA-LAPP/PHOENIX_LIBS2/PhoenixHPCProxy/build/TESTS/PERFORMANCE_TESTS/PERF_HADAMARD_PROXY_CMAKE/HadamardProductProxy/libhadamard_product_cmake_perf_anyarch.so");
98 }else{
99 isLibFound = false;
100 }
101
102 fclose(fp);
103 return isLibFound;
104 }
105
106 ///Say if the current library is opened or not
107 /** @return true if the current library is opened, false otherwise
108 */
109 bool Hadamard_product_cmake_perfProxyLoader::isOpen() const{
110 return p_handle != NULL;
111 }
112
113 ///Close the current library
114 void Hadamard_product_cmake_perfProxyLoader::close(){
115 if(isOpen()){
116 dlclose(p_handle);
117 }
118 }
119
120 ///Update the functions to be used
121 void Hadamard_product_cmake_perfProxyLoader::updateFunction(){
122 if(!isOpen()){exit(-1);return;}
123 //Then set all the function pointers
124 update_hadamard_product(p_handle);
125 }
126
127 ///Initialisation function of the class Hadamard_product_cmake_perfProxyLoader
128 void Hadamard_product_cmake_perfProxyLoader::initialisationHadamard_product_cmake_perfProxyLoader(){
129 p_handle = NULL;
130 }
131
132