Intel® oneAPI Data Parallel C++
Support for Intel® oneAPI DPC++ Compiler, Intel® oneAPI DPC++ Library, Intel ICX Compiler , Intel® DPC++ Compatibility Tool, and GDB*
560 Discussions

Version mismatch between Gcov and DPC++ while attempting to generate a code coverage report

Paavan_Joshi
Employee
2,687 Views

The procedures taken to generate code coverage for dpcpp.

- Updated Makefile and included gcov-specific parameters for compiling individual cpp files (-fPIC -fprofile-arcs ftest-coverage)

- It produced .gcno files.

- Executable code produced .gcda files for individual code files.

- The gcov command is required to provide a code coverage report. ->gcov file.cpp main.cpp

 

- error appears during this :- 

              main.gcno:version '408*', prefer 'A94*'

              make: *** [Makefile:99: gcov] Segmentation fault (core dump)

 

Labels (1)
0 Kudos
11 Replies
VidyalathaB_Intel
Moderator
2,665 Views

Hi Paavan,


Thanks for reaching out to us.


Could you please provide us with a sample reproducer and steps to reproduce the issue so that we can check it from our end to proceed further in this case?

Please do let us know the dpcpp version you are working with along with your OS details.


Regards,

Vidya.


0 Kudos
Paavan_Joshi
Employee
2,659 Views

OS and DPC++ version details. 

$ dpcpp -v
Intel(R) oneAPI DPC++/C++ Compiler 2022.1.0 (2022.1.0.20220316)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tester/intel/oneapi/compiler/2022.1.0/linux/bin-llvm
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

 

 

0 Kudos
VidyalathaB_Intel
Moderator
2,642 Views

Hi Paavan,


Thanks for sharing the details.


Could you please provide us with the source code if possible or any sample reproducer code along with the steps to reproduce the error so that we can test it from our end?


Regards,

Vidya.


0 Kudos
Paavan_Joshi
Employee
2,615 Views

Hi Vidya,

      Sorry for the late response.

      Hear is the sample code and required detail to setup and run.

 

main.cpp

 

#include <CL/sycl.hpp>
#include <iostream>
using namespace sycl;
const std::string secret {
    "Ifmmp-!xpsme\"\012J(n!tpssz-!Ebwf/!"
        "J(n!bgsbje!J!dbo(u!ep!uibu/!.!IBM\01"};
const auto sz = secret.size();
int main() {
    queue Q;
    char*result = malloc_shared<char>(sz, Q);
    std::memcpy(result,secret.data(),sz);
    Q.parallel_for(sz,[=](auto&i) {
            result[i] -= 1;
            }).wait();
    std::cout << result << "\n";
    return 0;
}

 

dpc_common.hpp


#ifndef _DP_HPP
#define _DP_HPP
#include <stdlib.h>
#include <exception>
#include <CL/sycl.hpp>
namespace dpc_common {
    static auto exception_handler = [](cl::sycl::exception_list eList) {
          for (std::exception_ptr const &e : eList) {
                  try {
                            std::rethrow_exception(e);
                            } catch (std::exception const &e) {
#if _DEBUG
                                  std::cout << "Failure" << std::endl;
#endif
                                        std::terminate();
                                        }
                    }
    };
    class TimeInterval {
         public:
               TimeInterval() : start_(std::chrono::steady_clock::now()) {}
                 double Elapsed() {
                         auto now = std::chrono::steady_clock::now();
                         return std::chrono::duration_cast<Duration>(now - start_).count();
                           }
                  private:
                   using Duration = std::chrono::duration<double>;
                     std::chrono::steady_clock::time_point start_;
    };
}; 
#endif

 


makefile

 

CC  = dpcpp
CFLAG = -fPIC -fprofile-arcs -ftest-coverage
RM  = rm -rf
help: ## Makefile help
    @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
main.o: main.cpp
    $(CC) $(CFLAG) -c -Wall  main.cpp
build: main.o ## Make build
    $(CC) $(CFLAG) -c -Wall  main.cpp
    $(CC) $(CFLAG) -o main main.o 
coverage: ## Run code coverage
    gcov main.cpp  
lcov-report: coverage ## Generate lcov report
    mkdir lcov-report
    lcov --capture --directory . --output-file lcov-report/coverage.info
    genhtml lcov-report/coverage.info --output-directory lcov-report
gcovr-report: coverage ## Generate gcovr report
    mkdir gcovr-report
    gcovr --root . --html --html-details --output gcovr-report/coverage.html
deps: ## Install dependences
    sudo apt-get install lcov
    pip install gcovr
clean: ## Clean all generate files
    $(RM) main *.o *.so *.gcno *.gcda *.gcov lcov-report gcovr-report

 

 

Commands with its output to build, run and generate code coverage report :- 

- ls (before code compile)


dpc_common.hpp   main.cpp   makefile

- make build

- ls


dpc_common.hpp   main   main.cpp   main.gcno   main.o   makefile



- main

   - Gives respected code op

- ls

dpc_common.hpp   main   main.cpp   main.gcda   main.gcno   main.o   makefile



- make coverage


gcno main.cpp

main.gcno:version '408*', prefer 'B13*'

make: *** [Makefile:17: coverage] Segmentation fault (core dump)


Thanks,

Paavan

0 Kudos
VidyalathaB_Intel
Moderator
2,555 Views

Hi Paavan ,

 

Thanks for your providing us with the details.

We use Clang based option sets for code coverage

Please refer to the below link for more details

https://clang.llvm.org/docs/SourceBasedCodeCoverage.html

 

I've modified the makefile with the options available in Clang.

 

CC  = dpcpp
CFLAG = -fprofile-instr-generate -fcoverage-mapping
RM  = rm -rf
export LLVM__ROOT = /opt/intel/oneapi/compiler/2022.2.1/linux/bin-llvm
help: ## Makefile help
        @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
main.o: main.cpp
        $(CC) $(CFLAG) -c -Wall  main.cpp
build: main.o ## Make build
        $(CC) $(CFLAG) -c -Wall  main.cpp
        $(CC) $(CFLAG) -o main main.o
coverage: ## Run code coverage
        LLVM_PROFILE_FILE="main.profraw" ./main
#llvm-cov: coverage ## Generate lcov report
        $(LLVM__ROOT)/llvm-profdata merge -sparse main.profraw -o main.profdata
#llvm-profdata: coverage ## Generate gcovr report
        $(LLVM__ROOT)/llvm-cov report ./main -instr-profile=main.profdata
#deps: ## Install dependences
#    sudo apt-get install lcov
#    pip install gcovr
clean: ## Clean all generate files
        $(RM) main *.o *.profdata *.profraw

 

Both llvm-cov and llvm-profdata merge are in our builds and you can find them under the following location /opt/intel/oneapi/compiler/2022.2.1/linux/bin-llvm/

 

Steps followed:

>  make build

>  make coverage

 

Please try it and let us know if you have any issues.

 

Regards,

Vidya.

 

0 Kudos
VidyalathaB_Intel
Moderator
2,360 Views

Hi @Paavan_Joshi ,

 

As we haven't heard back from you, could you please provide us with an update regarding the issue?

 

Regards,

Vidya.

 

0 Kudos
Paavan_Joshi
Employee
2,343 Views

Hello, Vidya.

I tested this method and it works good, but we wrote some test cases using the Gtest framework, thus we need to use gcove to generate coverage reports, or is there another way to generate coverage reports by modifying the cmake file?

 

Thanks,

Paavan

0 Kudos
VidyalathaB_Intel
Moderator
2,309 Views

Hi Paavan,

 

>>we wrote some test cases using the Gtest framework, thus we need to use gcove to generate coverage reports, or is there another way to generate coverage reports by modifying the cmake file?

Could you please let us know if you are facing any issues with the provided options with respect to clang in the makefile while generating code coverage reports for the application in which you have used Gtest framework?

Please elaborate more on your issue so that it would help us better in understanding the issue.

 

Regards,

Vidya.

 

0 Kudos
VidyalathaB_Intel
Moderator
2,232 Views

Hi Paavan,


As we haven't heard back from you, could you please provide us with an update regarding the issue?


Regards,

Vidya.


0 Kudos
Paavan_Joshi
Employee
2,221 Views

Hi Vidya,

 

Sorry for the delayed response, however I tried the same method with my test cases and it provided me with a coverage report.
So we can put this matter to rest.

And thank you for your help.

 

Thanks, 

Paavan

0 Kudos
VidyalathaB_Intel
Moderator
1,929 Views

Hi Paavan,


>>So we can put this matter to rest.

Thanks for the confirmation!

As the issue is addressed we are closing this thread. Please post a new question if you need any additional assistance from Intel as this thread will no longer be monitored.


Regards,

Vidya.


0 Kudos
Reply