I suspect this is very simple, but I'm not sure if this is a naive way to do this in Java. Heres my problem, I have two scenarios for processing data, and both have the same I / O, except that one is written for one processor and the other for GPUs. The work comes from the queue server, and I'm trying to write a program that sends data to a CPU or GPU script, depending on which one is free.
I donβt understand how to do this.
I know that with the help of the executorservice I can specify how many threads I want to keep working, but I'm not sure how to balance between two different ones. I have 2 GPUs and 8 processor cores in the system, and I thought that I would have support for three processors and 8 processors, but are not sure how to balance them, since the GPU will run much faster than the CPU tasks.
Any suggestions on how to approach this? Do I have to create two lines and collect them to see which one is less busy? or is there a way to simply put all the work units (after all) in one queue and execute the GPU or CPU process from one queue, since they are free?
UPDATE: just clarify. CPU / GPU programs go beyond the scope of the program I create, these are just scripts that I invoke in two different ways. I assume that a simplified version of what I am asking is that two methods can work from the same queue?
source share