JuliaGPU / JuliaGPU/KernelAbstractions.jl

[FR] Add nthreads argument to CPU backend

Open
#507 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
523
Forks
88
Avg merge
1d 11h
Merged PRs (30d)
25

Description

Hi! First of all congratulations on the fantastic package :)

Sometimes, seeing how the speed scales as a function of the number of threads is helpful.

My understanding is that right now the only way to change this is to run Julia differently julia --nthreads=X, and KA uses Julia's Threads.nthreads() (L95 here) to launch different processes:

https://github.com/JuliaGPU/KernelAbstractions.jl/blob/bafa3ccf706d1723aee5dcedf4180ca1c5dc16cb/src/cpu.jl#L93-L100

Could this be an argument of the CPU backend? For example, launching a kernel with CPU(8) would run with 8 threads (if 8 <= Threads.nthreads()). So we don't need to restart Julia with a different number of threads.

Obviously it doesn't need to be an argument in the backend, there might be a better way to implement this

Forgive me if there is a way to do this that I haven't realized.

Cheers!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/cpu.jl around lines 93-100 and review how Julia's Threads.nthreads() is used to launch CPU processes. Determine how a CPU backend thread-count argument could limit execution without restarting Julia, including the stated constraint that it must not exceed Threads.nthreads(); done means the behavior is implemented and validated for CPU(8).

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend, hpc
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.