Task 3 – Kernel Execution (10 marks) Write an OpenCL program that uses a kernel (you will have to write the kernel yours
Posted: Wed Apr 27, 2022 3:47 pm
Task 3 – Kernel Execution (10 marks) Write an OpenCL program that uses a kernel (you will have to write the kernel yourself) to fill in the contents of an array of 1024 numbers in parallel. The program is to prompt the user to enter a number between 1 and 89 (inclusive). The program is to check whether the user entered a valid number, if not the program will quit. If a valid number was entered, enqueue a kernel (using the enqueueNDRangeKernel function) that accepts the number and an array, and fills in the contents of the array using the number (and the work-items' global IDs) as follows: If the user enters 1, the resulting contents of the array should be: 1, 2, 3, 4, 5,... until 1024 If the user enters 2, the resulting contents of the array should be: 1, 3, 5, 7, 9,... until 2047 If the user enters 3, the resulting contents of the array should be: 1, 4, 7, 10, 13,... until 3070 . . If the user enters 89, the resulting contents of the array should be: 1, 90, 179, 268, 357,... until 91048 After kernel execution, display the resulting contents on screen.