Measuring Time inside kernel on intel iGPU











up vote
2
down vote

favorite












I am very new to OpenCL, however I have fair amount of experience on GPU programming using CUDA. I used to use clock function inside CUDA kernel (as mentioned in here) to measure ticks of certain operations inside the kernel. I wrote a simple OpenCL vector addition kernel and tried to run it on the intel integrated GPU. The program ran fine and gave correct output. But then I tried to use the clock function inside the kernel function and there is JIT compilation error while executing the clBuildProgram. The vector addition kernel that I wanted to execute is provided below:



__kernel void testVecAdd(__global const int *a,__global const int *b,__global int *c,
__global float *t){

clock_t start = clock();

int gid = get_global_id(0);
c[gid] = a[gid] + b[gid];

t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;

}


The errors are as follows:



/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:6:2: error: use of undeclared identifier 'clock_t'
clock_t start = clock();
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:19: error: implicit declaration of function 'clock' is invalid in OpenCL
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:27: error: use of undeclared identifier 'start'; did you mean 'sqrt'?
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^~~~~
sqrt
CTHeader.h:5277:40: note: 'sqrt' declared here
double16 __attribute__((overloadable)) sqrt(double16);
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:27: error: taking address of function is not allowed
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:34: error: use of undeclared identifier 'CLOCKS_PER_SEC'
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^

Failed to build program...: -11 (CL_BUILD_PROGRAM_FAILURE)
Build failed!


I was able to do this in the CUDA as it supports clock function. But similar goals was not achieved with the intel iGPU. I also tried other functions to measure the ticks but none of them worked as well. I also tried offline compilation using ioc64 but I got same errors. I was just wondering if someone could tell me is there anything wrong I am doing in here or getting the ticks using clock (or similar) functions is not possible in the intel integrated GPU. It is absolutely necessary for me to get this execution traces. So if using clock function is not a viable option then I was wondering what would be the alternate option in here to achieve same goals and how can I use it? Thank you.










share|improve this question
























  • What lead you to believe that clock() was supported in OpenCL. 10 seconds searching the OpenCL 2.0 specification shows that it isn't.
    – talonmies
    Nov 5 at 6:46






  • 1




    Possible duplicate of clock() in opencl
    – talonmies
    Nov 5 at 6:47










  • @talonmies thank you for your comments..but still your comments doesn't answer the question as I am looking for something similar to clock...as I already said that it is kind of evident that clock or similar functions are not supported...so something that serves the similar purpose ..this paper (comparch.gatech.edu/hparch/papers/gera_ispass18.pdf) mentioned about the GTPin tool that does it.....
    – duttasankha
    Nov 5 at 18:44












  • It wasn't intended as an answer. I am trying to understand what the purpose of posting a bunch of error messages and code which you apparently already know won't and can't work?
    – talonmies
    Nov 5 at 18:51










  • I think you are too much fixated with your opinion when I am saying repeatedly that I am looking for an ALTERNATE WAY of achieving similar goals...I don't know how much more I could be clear about this....if you have any tips for that then it would be highly appreciated rather than just defying me...thanks...
    – duttasankha
    Nov 5 at 19:44















up vote
2
down vote

favorite












I am very new to OpenCL, however I have fair amount of experience on GPU programming using CUDA. I used to use clock function inside CUDA kernel (as mentioned in here) to measure ticks of certain operations inside the kernel. I wrote a simple OpenCL vector addition kernel and tried to run it on the intel integrated GPU. The program ran fine and gave correct output. But then I tried to use the clock function inside the kernel function and there is JIT compilation error while executing the clBuildProgram. The vector addition kernel that I wanted to execute is provided below:



__kernel void testVecAdd(__global const int *a,__global const int *b,__global int *c,
__global float *t){

clock_t start = clock();

int gid = get_global_id(0);
c[gid] = a[gid] + b[gid];

t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;

}


The errors are as follows:



/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:6:2: error: use of undeclared identifier 'clock_t'
clock_t start = clock();
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:19: error: implicit declaration of function 'clock' is invalid in OpenCL
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:27: error: use of undeclared identifier 'start'; did you mean 'sqrt'?
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^~~~~
sqrt
CTHeader.h:5277:40: note: 'sqrt' declared here
double16 __attribute__((overloadable)) sqrt(double16);
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:27: error: taking address of function is not allowed
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:34: error: use of undeclared identifier 'CLOCKS_PER_SEC'
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^

Failed to build program...: -11 (CL_BUILD_PROGRAM_FAILURE)
Build failed!


I was able to do this in the CUDA as it supports clock function. But similar goals was not achieved with the intel iGPU. I also tried other functions to measure the ticks but none of them worked as well. I also tried offline compilation using ioc64 but I got same errors. I was just wondering if someone could tell me is there anything wrong I am doing in here or getting the ticks using clock (or similar) functions is not possible in the intel integrated GPU. It is absolutely necessary for me to get this execution traces. So if using clock function is not a viable option then I was wondering what would be the alternate option in here to achieve same goals and how can I use it? Thank you.










share|improve this question
























  • What lead you to believe that clock() was supported in OpenCL. 10 seconds searching the OpenCL 2.0 specification shows that it isn't.
    – talonmies
    Nov 5 at 6:46






  • 1




    Possible duplicate of clock() in opencl
    – talonmies
    Nov 5 at 6:47










  • @talonmies thank you for your comments..but still your comments doesn't answer the question as I am looking for something similar to clock...as I already said that it is kind of evident that clock or similar functions are not supported...so something that serves the similar purpose ..this paper (comparch.gatech.edu/hparch/papers/gera_ispass18.pdf) mentioned about the GTPin tool that does it.....
    – duttasankha
    Nov 5 at 18:44












  • It wasn't intended as an answer. I am trying to understand what the purpose of posting a bunch of error messages and code which you apparently already know won't and can't work?
    – talonmies
    Nov 5 at 18:51










  • I think you are too much fixated with your opinion when I am saying repeatedly that I am looking for an ALTERNATE WAY of achieving similar goals...I don't know how much more I could be clear about this....if you have any tips for that then it would be highly appreciated rather than just defying me...thanks...
    – duttasankha
    Nov 5 at 19:44













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I am very new to OpenCL, however I have fair amount of experience on GPU programming using CUDA. I used to use clock function inside CUDA kernel (as mentioned in here) to measure ticks of certain operations inside the kernel. I wrote a simple OpenCL vector addition kernel and tried to run it on the intel integrated GPU. The program ran fine and gave correct output. But then I tried to use the clock function inside the kernel function and there is JIT compilation error while executing the clBuildProgram. The vector addition kernel that I wanted to execute is provided below:



__kernel void testVecAdd(__global const int *a,__global const int *b,__global int *c,
__global float *t){

clock_t start = clock();

int gid = get_global_id(0);
c[gid] = a[gid] + b[gid];

t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;

}


The errors are as follows:



/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:6:2: error: use of undeclared identifier 'clock_t'
clock_t start = clock();
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:19: error: implicit declaration of function 'clock' is invalid in OpenCL
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:27: error: use of undeclared identifier 'start'; did you mean 'sqrt'?
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^~~~~
sqrt
CTHeader.h:5277:40: note: 'sqrt' declared here
double16 __attribute__((overloadable)) sqrt(double16);
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:27: error: taking address of function is not allowed
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:34: error: use of undeclared identifier 'CLOCKS_PER_SEC'
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^

Failed to build program...: -11 (CL_BUILD_PROGRAM_FAILURE)
Build failed!


I was able to do this in the CUDA as it supports clock function. But similar goals was not achieved with the intel iGPU. I also tried other functions to measure the ticks but none of them worked as well. I also tried offline compilation using ioc64 but I got same errors. I was just wondering if someone could tell me is there anything wrong I am doing in here or getting the ticks using clock (or similar) functions is not possible in the intel integrated GPU. It is absolutely necessary for me to get this execution traces. So if using clock function is not a viable option then I was wondering what would be the alternate option in here to achieve same goals and how can I use it? Thank you.










share|improve this question















I am very new to OpenCL, however I have fair amount of experience on GPU programming using CUDA. I used to use clock function inside CUDA kernel (as mentioned in here) to measure ticks of certain operations inside the kernel. I wrote a simple OpenCL vector addition kernel and tried to run it on the intel integrated GPU. The program ran fine and gave correct output. But then I tried to use the clock function inside the kernel function and there is JIT compilation error while executing the clBuildProgram. The vector addition kernel that I wanted to execute is provided below:



__kernel void testVecAdd(__global const int *a,__global const int *b,__global int *c,
__global float *t){

clock_t start = clock();

int gid = get_global_id(0);
c[gid] = a[gid] + b[gid];

t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;

}


The errors are as follows:



/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:6:2: error: use of undeclared identifier 'clock_t'
clock_t start = clock();
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:19: error: implicit declaration of function 'clock' is invalid in OpenCL
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:27: error: use of undeclared identifier 'start'; did you mean 'sqrt'?
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^~~~~
sqrt
CTHeader.h:5277:40: note: 'sqrt' declared here
double16 __attribute__((overloadable)) sqrt(double16);
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:27: error: taking address of function is not allowed
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^
/home/duttasankha/Desktop/SANKHA_ALL/IGPU_RESEARCH_RELATED/OCL_PRAC_DIR/test_OCL_1.cl:11:34: error: use of undeclared identifier 'CLOCKS_PER_SEC'
t[gid] = (float)(clock()-start)/CLOCKS_PER_SEC;
^

Failed to build program...: -11 (CL_BUILD_PROGRAM_FAILURE)
Build failed!


I was able to do this in the CUDA as it supports clock function. But similar goals was not achieved with the intel iGPU. I also tried other functions to measure the ticks but none of them worked as well. I also tried offline compilation using ioc64 but I got same errors. I was just wondering if someone could tell me is there anything wrong I am doing in here or getting the ticks using clock (or similar) functions is not possible in the intel integrated GPU. It is absolutely necessary for me to get this execution traces. So if using clock function is not a viable option then I was wondering what would be the alternate option in here to achieve same goals and how can I use it? Thank you.







gpu opencl intel gpgpu






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 5 at 1:30

























asked Nov 5 at 1:13









duttasankha

3522623




3522623












  • What lead you to believe that clock() was supported in OpenCL. 10 seconds searching the OpenCL 2.0 specification shows that it isn't.
    – talonmies
    Nov 5 at 6:46






  • 1




    Possible duplicate of clock() in opencl
    – talonmies
    Nov 5 at 6:47










  • @talonmies thank you for your comments..but still your comments doesn't answer the question as I am looking for something similar to clock...as I already said that it is kind of evident that clock or similar functions are not supported...so something that serves the similar purpose ..this paper (comparch.gatech.edu/hparch/papers/gera_ispass18.pdf) mentioned about the GTPin tool that does it.....
    – duttasankha
    Nov 5 at 18:44












  • It wasn't intended as an answer. I am trying to understand what the purpose of posting a bunch of error messages and code which you apparently already know won't and can't work?
    – talonmies
    Nov 5 at 18:51










  • I think you are too much fixated with your opinion when I am saying repeatedly that I am looking for an ALTERNATE WAY of achieving similar goals...I don't know how much more I could be clear about this....if you have any tips for that then it would be highly appreciated rather than just defying me...thanks...
    – duttasankha
    Nov 5 at 19:44


















  • What lead you to believe that clock() was supported in OpenCL. 10 seconds searching the OpenCL 2.0 specification shows that it isn't.
    – talonmies
    Nov 5 at 6:46






  • 1




    Possible duplicate of clock() in opencl
    – talonmies
    Nov 5 at 6:47










  • @talonmies thank you for your comments..but still your comments doesn't answer the question as I am looking for something similar to clock...as I already said that it is kind of evident that clock or similar functions are not supported...so something that serves the similar purpose ..this paper (comparch.gatech.edu/hparch/papers/gera_ispass18.pdf) mentioned about the GTPin tool that does it.....
    – duttasankha
    Nov 5 at 18:44












  • It wasn't intended as an answer. I am trying to understand what the purpose of posting a bunch of error messages and code which you apparently already know won't and can't work?
    – talonmies
    Nov 5 at 18:51










  • I think you are too much fixated with your opinion when I am saying repeatedly that I am looking for an ALTERNATE WAY of achieving similar goals...I don't know how much more I could be clear about this....if you have any tips for that then it would be highly appreciated rather than just defying me...thanks...
    – duttasankha
    Nov 5 at 19:44
















What lead you to believe that clock() was supported in OpenCL. 10 seconds searching the OpenCL 2.0 specification shows that it isn't.
– talonmies
Nov 5 at 6:46




What lead you to believe that clock() was supported in OpenCL. 10 seconds searching the OpenCL 2.0 specification shows that it isn't.
– talonmies
Nov 5 at 6:46




1




1




Possible duplicate of clock() in opencl
– talonmies
Nov 5 at 6:47




Possible duplicate of clock() in opencl
– talonmies
Nov 5 at 6:47












@talonmies thank you for your comments..but still your comments doesn't answer the question as I am looking for something similar to clock...as I already said that it is kind of evident that clock or similar functions are not supported...so something that serves the similar purpose ..this paper (comparch.gatech.edu/hparch/papers/gera_ispass18.pdf) mentioned about the GTPin tool that does it.....
– duttasankha
Nov 5 at 18:44






@talonmies thank you for your comments..but still your comments doesn't answer the question as I am looking for something similar to clock...as I already said that it is kind of evident that clock or similar functions are not supported...so something that serves the similar purpose ..this paper (comparch.gatech.edu/hparch/papers/gera_ispass18.pdf) mentioned about the GTPin tool that does it.....
– duttasankha
Nov 5 at 18:44














It wasn't intended as an answer. I am trying to understand what the purpose of posting a bunch of error messages and code which you apparently already know won't and can't work?
– talonmies
Nov 5 at 18:51




It wasn't intended as an answer. I am trying to understand what the purpose of posting a bunch of error messages and code which you apparently already know won't and can't work?
– talonmies
Nov 5 at 18:51












I think you are too much fixated with your opinion when I am saying repeatedly that I am looking for an ALTERNATE WAY of achieving similar goals...I don't know how much more I could be clear about this....if you have any tips for that then it would be highly appreciated rather than just defying me...thanks...
– duttasankha
Nov 5 at 19:44




I think you are too much fixated with your opinion when I am saying repeatedly that I am looking for an ALTERNATE WAY of achieving similar goals...I don't know how much more I could be clear about this....if you have any tips for that then it would be highly appreciated rather than just defying me...thanks...
– duttasankha
Nov 5 at 19:44

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147100%2fmeasuring-time-inside-kernel-on-intel-igpu%23new-answer', 'question_page');
}
);

Post as a guest





































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147100%2fmeasuring-time-inside-kernel-on-intel-igpu%23new-answer', 'question_page');
}
);

Post as a guest




















































































這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini