Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6113487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:51:53+00:00 2026-05-23T14:51:53+00:00

I trying to use OpenCL using HASKELL. I write a simple program converting a

  • 0

I trying to use OpenCL using HASKELL. I write a simple program converting a working one in C. It appears to work well, but when I assign a memory object to the kernel parameters, it fails with CL_INVALID_MEM_OBJECT error. I don’t know who to fix because I use the same calls than in C program and there it works:

The programSource is the OpenCL code

programSource :: String
programSource = "__kernel void duparray(__global float *in, __global float *out ){  int id = get_global_id(0); out[id] = 2*in[id]; }"

And the initializacion works until the call of clSetKernelArg that fails with Just (ErrorCode (-38))

-- test openCL
input  <- newArray ([0,1,2,3,4] :: [CFloat])

Right mem_in <- clCreateBuffer myContext (memFlagsJoin [clMemReadOnly,clMemCopyHostPtr]) (4*5) (castPtr input)
Right mem_out <- clCreateBuffer myContext clMemWriteOnly (4*5) nullPtr
print (mem_in,mem_out)
Right program <- clCreateProgramWithSource myContext programSource
print program

err <- clBuildProgram program [myDeviceId] "" buildProgramCallback nullPtr
print err

Right kernel <- clCreateKernel program "duparray"
print kernel

kaErr0 <- clSetKernelArg kernel 0 (fromIntegral.sizeOf $ mem_in) (castPtr mem_in)
kaErr1 <- clSetKernelArg kernel 1 (fromIntegral.sizeOf $ mem_out) (castPtr mem_out)
print (kaErr0,kaErr1)

I’m using OpenCLRaw, with several modifications that i put on https://github.com/zhensydow/OpenCLRaw

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:51:54+00:00Added an answer on May 23, 2026 at 2:51 pm

    I found that I need to pass the direction of the mem buffer pointer, no the pointer itself. This is the rigth way to call clSetKernelArg:

    dir_mem_in <- (malloc :: IO (Ptr Mem)) 
    poke dir_mem_in mem_in
    kaErr0 <- clSetKernelArg kernel 0 (fromIntegral.sizeOf $ mem_in) (castPtr dir_mem_in)
    dir_mem_out <- (malloc :: IO (Ptr Mem)) 
    poke dir_mem_out mem_out
    kaErr1 <- clSetKernelArg kernel 1 (fromIntegral.sizeOf $ mem_out) (castPtr dir_mem_out)
    print (kaErr0, kaErr1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use OpenGL with Monodroid, but by using get Unhandled Exception not
Trying to use a guid as a resource id in a rest url but
I was trying to use the function glMultiDrawElements while studying OpenGL (using red book)
I'm write a simple graphic-based program in Assembly for learning purpose; for this, I
I am trying to use GL_TEXTURE_BINDING_2D in my code, but it won't compile under
I'm trying to use a texture atlas in a game program I'm writing in
I am trying to write a program to analyze emotional expressions like tears. As
I'm trying to use opengl in C#. I have following code which fails with
Trying to use an excpetion class which could provide location reference for XML parsing,
While trying to use LINQ to SQL I encountered several problems. I have table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.