Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #339 from hujiajie/fix-webcl-profiling-info
Browse files Browse the repository at this point in the history
[WebCL] Let WebCLEvent.prototype.getProfilingInfo() return 64-bit pro…
  • Loading branch information
rakuco committed Apr 8, 2016
2 parents 54e413c + bceae30 commit 64e558d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions third_party/WebKit/Source/modules/webcl/WebCLEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,20 @@ int WebCLEvent::getStatus()
return CL_INVALID_VALUE;
}

unsigned WebCLEvent::getProfilingInfo(int paramName, ExceptionState& es)
ScriptValue WebCLEvent::getProfilingInfo(ScriptState* scriptState, unsigned paramName, ExceptionState& es)
{
v8::Isolate* isolate = scriptState->isolate();

if (isReleased()) {
es.throwWebCLException(WebCLException::INVALID_EVENT, WebCLException::invalidEventMessage);
return 0;
return ScriptValue(scriptState, v8::Null(isolate));
}

int status = getStatus();
unsigned properties = m_commandQueue ? m_commandQueue->getProperties() : 0;
if (isUserEvent() || status != CL_COMPLETE || !(properties & CL_QUEUE_PROFILING_ENABLE)) {
es.throwWebCLException(WebCLException::PROFILING_INFO_NOT_AVAILABLE, WebCLException::profilingInfoNotAvailableMessage);
return 0;
return ScriptValue(scriptState, v8::Null(isolate));
}

cl_int err = CL_SUCCESS;
Expand All @@ -104,30 +106,30 @@ unsigned WebCLEvent::getProfilingInfo(int paramName, ExceptionState& es)
case CL_PROFILING_COMMAND_QUEUED:
err = clGetEventProfilingInfo(m_clEvent, CL_PROFILING_COMMAND_QUEUED, sizeof(cl_ulong), &ulongUnits, nullptr);
if (err == CL_SUCCESS)
return static_cast<unsigned long long>(ulongUnits);
return ScriptValue(scriptState, v8::Number::New(isolate, static_cast<double>(ulongUnits)));
break;
case CL_PROFILING_COMMAND_SUBMIT:
err = clGetEventProfilingInfo(m_clEvent, CL_PROFILING_COMMAND_SUBMIT, sizeof(cl_ulong), &ulongUnits, nullptr);
if (err == CL_SUCCESS)
return static_cast<unsigned long long>(ulongUnits);
return ScriptValue(scriptState, v8::Number::New(isolate, static_cast<double>(ulongUnits)));
break;
case CL_PROFILING_COMMAND_START:
err = clGetEventProfilingInfo(m_clEvent, CL_PROFILING_COMMAND_START, sizeof(cl_ulong), &ulongUnits, nullptr);
if (err == CL_SUCCESS)
return static_cast<unsigned long long>(ulongUnits);
return ScriptValue(scriptState, v8::Number::New(isolate, static_cast<double>(ulongUnits)));
break;
case CL_PROFILING_COMMAND_END:
err = clGetEventProfilingInfo(m_clEvent, CL_PROFILING_COMMAND_END, sizeof(cl_ulong), &ulongUnits, nullptr);
if (err == CL_SUCCESS)
return static_cast<unsigned long long>(ulongUnits);
return ScriptValue(scriptState, v8::Number::New(isolate, static_cast<double>(ulongUnits)));
break;
default:
es.throwWebCLException(WebCLException::INVALID_VALUE, WebCLException::invalidValueMessage);
return 0;
return ScriptValue(scriptState, v8::Null(isolate));
}

WebCLException::throwException(err, es);
return 0;
return ScriptValue(scriptState, v8::Null(isolate));
}

void WebCLEvent::setCallback(unsigned commandExecCallbackType, WebCLCallback* callback, ExceptionState& es)
Expand Down
2 changes: 1 addition & 1 deletion third_party/WebKit/Source/modules/webcl/WebCLEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class WebCLEvent : public WebCLObject, public ScriptWrappable {
static PassRefPtr<WebCLEvent> create();

virtual ScriptValue getInfo(ScriptState*, unsigned, ExceptionState&);
unsigned getProfilingInfo(int, ExceptionState&);
virtual ScriptValue getProfilingInfo(ScriptState*, unsigned, ExceptionState&);
void setCallback(unsigned, WebCLCallback*, ExceptionState&);
void release() override;

Expand Down
2 changes: 1 addition & 1 deletion third_party/WebKit/Source/modules/webcl/WebCLEvent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ typedef unsigned long long CLulong;
Constructor,
] interface WebCLEvent {
[CallWith=ScriptState, RaisesException] any getInfo(CLenum name);
[RaisesException] CLulong getProfilingInfo(CLenum name);
[CallWith=ScriptState, RaisesException] any getProfilingInfo(CLenum name);
[RaisesException] void setCallback(CLenum commandExecCallbackType,
WebCLCallback notify);
void release();
Expand Down

0 comments on commit 64e558d

Please sign in to comment.