i am trying to apply constraints on array such that the element present in array which are greater than 1 and 4, are completely divisible by that element. and such elements are stored in another array. How can I do that in GPU programming using GPLK library and JUMP library.

Iâ€™m not sure I understand your problem, can you explain in more detail what you are trying to do? And why does it have to be on a GPU?

thank you for reply , In normal julia program (CPU runnable) by applying constraint we get possible combinations of results for example x + y >3 give me possible combinations of x and y which addition should be less than 3 using GPLK and JuMP package . so i want to apply that condition on GPU program so how can i use it . I want to do it on GPU program due to performance issue

I have one CuArray in GPU program so i want those elements in that CuArray which are greater than 1 and that element completely divisible by 4 by using GPLK package if I got that solution then I can able to convert our CPU runnable julia program into GPU runnable

I donâ€™t think it matters much to JuMP whether your arrays live on the CPU or on the GPU, because the underlying solvers (like GLPK) are written in a different language anyway, so they wonâ€™t use the same objects. If youâ€™re facing performance issues, you are probably better off re-examining your modeling choices or switching solvers (GLPK is notoriously inefficient, try HiGHS instead).

EDIT: I asked the experts, and some solvers do support a GPU backend, like SCS. But most linear solvers donâ€™t.

As for your actual constraint, can you give me a mathematical formulation of the problem?

I just want to know that Can we use GLPK library in GPU programming? If yes then how?

this is my constraint below

for i in 1:length(array)

if (array[i] >= 2 && 4 % array[i] == 0)

@constraint(model, x[i] == 1)

end

end

For GLPK specifically I donâ€™t think itâ€™s possible. But Iâ€™m out of my depth here so Iâ€™m calling @odow

My best guess is, all it takes is to put all your problem parameters in `CuArray`

s instead of `Array`

s and let dispatch do the rest, but Iâ€™m not sure how to deal with variables because the documentation on variable containers does not mention GPU arrays.

thank you very much sir I will try that solution ,

and I also want to ask one question that how to know is my program is running on GPU.

For a simple, full-Julia program, I would say you need to check that all of the arrays you create still live on the GPU. Check out the CUDA.jl documentation for more details.

But since JuMP is full of metaprogramming and calls solvers in other languages, the task seems much harder and Iâ€™m afraid I cannot help you.

Okay ,Thank you sir

Iâ€™m not @odow, nor do I play him on television

From what you have written here, `x[i]`

will take the (binary?) value 1 only when `array[i] == 4`

. If this is what you meant then the following might work:

```
for i in 1:length(array)
@constraint(model, array[i] <= 4*x[i])
@constraint(model, 4*x[i] <= array[i])
end
```

This assumes that `0 <= array[i] <= 4`

. But maybe thatâ€™s not what you meantâ€¦

Sorry, I donâ€™t have any useful ideas on how to do this.

No, you cannot use GLPK on a GPU.

I really donâ€™t think so, at least not for the program resolution.

GLPK is a solver engine written in C++ for linear (and mixed integers) problems.

â€śGPU programmingâ€ť in Julia refers to execute Julia code in the GPU but I really donâ€™t think it is possible to run external calls to C interface in the GPU.

At the very best (and I highly doubt so) it could be possible to construct the model from the nice math-friendly format that is given to JuMP to the matrix format that the GLPK solver expects, but not the solving itself.

From your example perhaps this is what you want to doâ€¦ run the code of the `if`

block you posted above in the GPUâ€¦ in that case the solver engine to be used (GLPK) is ininfluentâ€¦ by the wayâ€¦ I notice that you use â€śGPLKâ€ť, are you referring to â€śGLPKâ€ť (GNU Linear Programming Kit), right ?

Thank you sir,

Is there any alternative way to GLPK to apply constraint in GPU program of julia

thank you sir , can you provide me alternative way to apply constraint on expression in GPU program of julia

As others have pointed out, why do you want this? A GPU will not make your code faster when using JuMP.

If your code is too slow, please start a new thread with a reproducible example of what youâ€™re trying to achieve.