예제 #1
0
  public static CudaEngine getCudaEngine(CudaObject co) {
    synchronized (cudaEngines) {
      if (!isCudaAvailable()) throw new CudaException("No cuda device found");
      try {
        initialization.awaitTermination(100, TimeUnit.SECONDS);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      Pheromone p = (Pheromone) co;
      final int pheroID = cudaObjectID.incrementAndGet();

      final CudaEngine ce = cudaEngines.get(pheroID % availableDevicesNb);
      //			final CudaEngine ce = cudaEngines.get(1);
      //			final CudaEngine ce = cudaEngines.get(0);

      //			final CudaEngine ce;
      //			if(p.getName().contains("PRE")){
      //				ce = cudaEngines.get(0);
      //			}
      //			else{
      //				ce = cudaEngines.get(1);
      //			}
      //
      ce.cudaObjects.add(co);
      System.err.println(co + "ID " + pheroID + " getting cuda engine Id " + ce.Id);
      return ce;
    }
  }
예제 #2
0
 private synchronized void shutdown() {
   if (!exe.isShutdown()) {
     freeCUObjectsMemory();
   }
   exe.shutdown();
   try {
     System.err.println(
         "cuda device " + Id + " freed ? " + exe.awaitTermination(10, TimeUnit.SECONDS));
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
 }