- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Team,
I tried to generate a code coverage report for my DPC++ code using llvm, but it is not displaying the correct result, even if each line of code is running.
Following some debugging, I discovered that it is not covering specific code under parallel for.
Sample code:-
main.cpp
#include <CL/sycl.hpp>
#include <iostream>
using namespace std;
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) {
// Temp/extra code start(This is added to increase code inside parallel_for)
result[i] -= 1;
result[i] += 1;
result[i] -= 1;
result[i] += 1;
result[i] -= 1;
result[i] += 1;
// Temp/extra code end..
result[i] -= 1;
});
Q.wait();
std::cout << result << "\n";
return 0;
}
makefile
CC = dpcpp
CFLAG = -fprofile-instr-generate -fcoverage-mapping
RM = rm -rf
export LLVM__ROOT = /opt/intel/oneapi/compiler/2022.1.0/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) -o main main.o
coverage: ## Run code coverage
LLVM_PROFILE_FILE="main.profraw" ./main
$(LLVM__ROOT)/llvm-profdata merge -sparse main.profraw -o main.profdata
$(LLVM__ROOT)/llvm-cov report ./main -instr-profile=main.profdata
clean: ## Clean all generate files
$(RM) main *.o *.profdata *.profraw
Steps to generate code coverage,
$ make build
$ ./main
$ make coverage
Code coverage report :-
Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
main-0fb086.cpp 2 1 50.00% 2 1 50.00% 26 9 65.38% 0 0 -
main-header-16a1df.h 8 4 50.00% 8 4 50.00% 12 6 50.00% 0 0 -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL 10 5 50.00% 10 5 50.00% 38 15 60.53% 0 0 -
Could anyone help with identifying the problem and solution, please?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for posting in Intel Communities.
Could you please let us know the OS details, CPU, and GPU details you are using?
And also, could you please let us know on which device selector you are using by using the below command?
SYCL_PI_TRACE=1 ./main (./main is the executable that got generated)
>>but it is not displaying the correct result, even if each line of code is running.
Could you please let us know what are the expected results?
Thanks & Regards,
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Varsha,
>> Could you please let us know the OS details, CPU, and GPU details you are using?
- The output of clinfo is stored to a file and attached to the reply.
OS :- Ubuntu 20.04.5 LTS
cat /proc/cpuinfo
vendor_id : GenuineIntel
cpu family : 6
model : 190
model name : Genuine Intel(R) 0000
>> And also, could you please let us know on which device selector you are using by using the below command?
SYCL_PI_TRACE=1 ./main (./main is the executable that got generated)
SYCL_PI_TRACE[basic]: Plugin found and successfully loaded: libpi_opencl.so
SYCL_PI_TRACE[all]: Selected device ->
SYCL_PI_TRACE[all]: platform: Intel(R) OpenCL HD Graphics
SYCL_PI_TRACE[all]: device: Intel(R) Graphics [0x46d1]
Hello, world! I'm sorry, Dave. I'm afraid I can't do that. - HAL
-> cout << "Running on " << Q.get_device().get_info<info::device::name>()<< "\n";
Running on Intel(R) Graphics [0x46d1]
>> Could you please let us know what are the expected results?
As all the lines of main is executed, it should shows cover as 100% (for now its shoes as 50%).
Thanks & Regards,
Paavan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for providing the details.
The code coverage percentage shown by the general commands might not be significant. We should not read it as an absolute value of how much the "original" source codes have been covered.
>>As all the lines of main is executed, it should shows cover as 100% (for now its shoes as 50%).
And also, the compiler generates a lot of extra codes including the codes from the header files. So, the code coverage percentage will be generated based on all the lines of code generated by the compiler.
I hope this helps resolve your query.
Thanks & Regards,
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Varsha
However, even if I add more lines of code inside a particular parallel_for, the percentage of code coverage will still decrease.
Please check the attached screenshots:-
1 line of code inside parallel_for :-
- covers :- 80% of code.
7 lines of code inside parallel_for :-
- covers :- 66.67% of code.
13 lines of code inside parallel_for :-
- covers :- 61.54% of code.
As a result of this discovery, I have a suspicion that it is not covering a certain parallel_for area of the code.
Thanks & Regards,
Paavan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Could you please provide us with any update on your issue(we have contacted you internally through the mail)?
Thanks & Regards,
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Varsha,
Replied back on same mail chain, please check.
>> As I am facing this issue on some project and that’s why I am using ADL-S/ADL-N board itself not intel OneCloud.
>> The problem is that, the code coverage itself doesn’t covers code inside parallel_for at all. Is there any way to cover that.
Can we connect on teams so we can discuss and look into it quickly?
Thanks and Regards,
Paavan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for your patience.
Apologies for the delay in my response. As Intel Code Coverage inherits the feature of the open source llvm.org(https://clang.llvm.org/docs/SourceBasedCodeCoverage.html).
Sorry for the inconvenience caused to you. As the issue is related to Clang Code Coverage so we suggest you file an issue on llvm.org GitHub (https://github.com/llvm/llvm-project/issues/).
Could you please let us know if you have any other queries related to Intel Compiler? If not, can we go ahead and close this thread?
Thanks & Regards,
Varsha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We have not heard back from you. This thread will no longer be monitored by Intel. If you need additional information, please start a new thread.
Thanks & Regards,
Varsha
![](/skins/images/D3C0B914909A6564BBB97F4AD1ED1973/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page