Find the answer to your Linux question:
Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By gregm
Hi, i'm a new user on this forum. I need know which kernel module i've to edit to assign the threads to CPU or CPU. I'm using kernel 3.2.54 Sorry ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2014
    Posts
    4

    Module CPU/GPU


    Hi, i'm a new user on this forum. I need know which kernel module i've to edit to assign the threads to CPU or CPU.
    I'm using kernel 3.2.54
    Sorry for my bad english.
    Thank you

  2. #2
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,286
    I'm not sure I understand the question but any kernel module can request a thread on a CPU.

    Code:
    // linux/kthread.h
    
    struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
    					  void *data,
    					  unsigned int cpu,
    					  const char *namefmt);

  3. #3
    Just Joined!
    Join Date
    Jan 2014
    Posts
    4
    Quote Originally Posted by gregm View Post
    I'm not sure I understand the question but any kernel module can request a thread on a CPU.

    Code:
    // linux/kthread.h
    
    struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
    					  void *data,
    					  unsigned int cpu,
    					  const char *namefmt);
    oh!!! I'm sorry.
    My question was: I need know which kernel module i've to edit to assign the threads to CPU or GPU.
    I want assign a thread,usually runs on CPU, to GPU.
    Does it depend on graphic hardaware or is there a general procedure in the code?
    does it refer to kernel or I've to work with openCL?
    thank you

  4. #4
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,286
    The drivers for the graphics card controls access to the GPU. If the device is OpenCL enabled you can access it through OpenCL - currently I believe limited to some AMD cards. If the card is a CUDA enabled device then you have access to the GPU through CUDA or OpenCL - this would be NVIDIA cards. When they talk about kernels in either of these technologies they are talking about compiled code that run on a GPU. It isn't the same thing as a Linux kernel module.

    Here's the NVIDIA documentation for CUDA on Linux: Getting Started Linux :: CUDA Toolkit Documentation.
    Here's a page from the OpenCL Cookbook that talks about kernels (the GPU type): OpenCL Cookbook: Creating programs and reading kernels from a file | Dhruba Bandopadhyay
    voidpointer69 likes this.

  5. #5
    Just Joined!
    Join Date
    Jan 2014
    Posts
    4
    ok, thank you.
    and than if i want assign some threads to GPU i've to work with OpenCL? i can't edit or write new code for kernel?

  6. #6
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,286
    If your asking if you can write a kernel module that uses opencl, I don't know. I'd suggest giving it a try - I can't see a reason why you couldn't.

    On the other hand I don't think you can assign kernel threads to the GPU - it doesn't make sense - they aren't the same sort of thread or processor - but someone may come along and say I'm wrong.

  7. #7
    Just Joined!
    Join Date
    Jan 2014
    Posts
    4
    ok. My target is assign to GPU some threads that kernel usually assign to CPU. I'm talking about jobs that perform mathematical calculations. It's a work for my Univeristiy thesis.
    Thank you a lot!

  8. #8
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,286
    Sound interesting but very challenging. Generally speaking the C libraries are the interface between user space and the kernel. Libmath is the general library for math functions. The source code for it may give you some ideas for how the interaction occurs. There are kernel space math libraries as well; they are specialized functions which doesn't sound like what you're attempting.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •