mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Merge pull request #314 from Dantali0n/fix-opencl-vectoradd
Fix OpenCLVectorAdd example
This commit is contained in:
commit
332c3aa242
@ -1,7 +1,10 @@
|
|||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
project(OpenCLVectorAdd)
|
project(OpenCLVectorAdd)
|
||||||
|
|
||||||
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
find_package(OpenCL REQUIRED)
|
find_package(OpenCL REQUIRED)
|
||||||
|
|
||||||
add_executable(OpenCLVectorAdd OpenCLVectorAdd.cpp)
|
add_executable(OpenCLVectorAdd OpenCLVectorAdd.cpp)
|
||||||
@ -11,4 +14,4 @@ add_library(TracyClient STATIC ../../TracyClient.cpp
|
|||||||
target_include_directories(TracyClient PUBLIC ../../)
|
target_include_directories(TracyClient PUBLIC ../../)
|
||||||
target_compile_definitions(TracyClient PUBLIC TRACY_ENABLE=1)
|
target_compile_definitions(TracyClient PUBLIC TRACY_ENABLE=1)
|
||||||
|
|
||||||
target_link_libraries(OpenCLVectorAdd PUBLIC OpenCL::OpenCL TracyClient)
|
target_link_libraries(OpenCLVectorAdd PUBLIC OpenCL::OpenCL TracyClient ${CMAKE_DL_LIBS} Threads::Threads)
|
||||||
|
@ -139,13 +139,14 @@ int main()
|
|||||||
|
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
|
int n_value = static_cast<int>(N);
|
||||||
ZoneScopedN("VectorAdd Kernel Launch");
|
ZoneScopedN("VectorAdd Kernel Launch");
|
||||||
TracyCLZoneC(tracyCLCtx, "VectorAdd Kernel", tracy::Color::Blue4);
|
TracyCLZoneC(tracyCLCtx, "VectorAdd Kernel", tracy::Color::Blue4);
|
||||||
|
|
||||||
CL_ASSERT(clSetKernelArg(vectorAddKernel, 0, sizeof(cl_mem), &bufferC));
|
CL_ASSERT(clSetKernelArg(vectorAddKernel, 0, sizeof(cl_mem), &bufferC));
|
||||||
CL_ASSERT(clSetKernelArg(vectorAddKernel, 1, sizeof(cl_mem), &bufferA));
|
CL_ASSERT(clSetKernelArg(vectorAddKernel, 1, sizeof(cl_mem), &bufferA));
|
||||||
CL_ASSERT(clSetKernelArg(vectorAddKernel, 2, sizeof(cl_mem), &bufferB));
|
CL_ASSERT(clSetKernelArg(vectorAddKernel, 2, sizeof(cl_mem), &bufferB));
|
||||||
CL_ASSERT(clSetKernelArg(vectorAddKernel, 3, sizeof(int), &static_cast<int>(N)));
|
CL_ASSERT(clSetKernelArg(vectorAddKernel, 3, sizeof(int), &n_value));
|
||||||
|
|
||||||
cl_event vectorAddKernelEvent;
|
cl_event vectorAddKernelEvent;
|
||||||
CL_ASSERT(clEnqueueNDRangeKernel(commandQueue, vectorAddKernel, 1, nullptr, &N, nullptr, 0, nullptr, &vectorAddKernelEvent));
|
CL_ASSERT(clEnqueueNDRangeKernel(commandQueue, vectorAddKernel, 1, nullptr, &N, nullptr, 0, nullptr, &vectorAddKernelEvent));
|
||||||
|
Loading…
Reference in New Issue
Block a user