O o o Task 2 - Data Management (8 marks) Write a program that uses OpenCL to do the following: Create a C++ vector of un
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
O o o Task 2 - Data Management (8 marks) Write a program that uses OpenCL to do the following: Create a C++ vector of un
O o o Task 2 - Data Management (8 marks) Write a program that uses OpenCL to do the following: Create a C++ vector of unsigned chars to store alphabets. Initialise its content to: a-z and A- Z (i.e. 52 alphabets in total). Create another C++ vector to store 512 unsigned ints. Initialise its content to: 1-512. (1 mark) Create three OpenCL memory objects (i.e. cl::Buffer objects): The first buffer is read-only and initialised with the contents of the alphabet vector. The second buffer is write-only and created to store 52 unsigned chars. The third buffer is read-and-write and created to store 512 unsigned ints. (2 marks) Enqueue two OpenCL commands: o To copy the contents from the first buffer into the second buffer. To write the contents from the vector of 512 integers into the third buffer. (2 marks) Setup the OpenCL program to allow the user to select one device, create a context and command queue for that device. Then, build the provided “task2.cl" program and create a kernel for "task2”. (1 mark) Set kernel arguments for the kernel that was previously created. For the first argument, pass a floating-point value of 21.43 to the kernel. For the second and third kernel arguments, set these to the second and third buffers that were previously created. Then, enqueue the kernel using the enqueue Task function. (1 mark) After returning from the enqueueTask function, read the contents from the two buffers, and display the results on screen. (1 mark) O
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!