if (isOdd(ht_off)) // if that's odd number, it's final result return ht_off;
@Override public void setSeed(long seed) { synchronized (this) { this.seed = seed; this.amplifier = seed; this.position.set(0); nativeOps.refreshBuffer(getExtraPointers(), seed, statePointer); } }
public Nd4jBlas() { int numThreads; String skipper = System.getenv("ND4J_SKIP_BLAS_THREADS"); if (skipper == null || skipper.isEmpty()) { String numThreadsString = System.getenv("OMP_NUM_THREADS"); if (numThreadsString != null && !numThreadsString.isEmpty()) { numThreads = Integer.parseInt(numThreadsString); setMaxThreads(numThreads); } else { int cores = Loader.totalCores(); int chips = Loader.totalChips(); if (cores > 0 && chips > 0) numThreads = Math.max(1, cores / chips); else numThreads = NativeOps.getCores(Runtime.getRuntime().availableProcessors()); setMaxThreads(numThreads); } log.info("Number of threads used for BLAS: {}", getMaxThreads()); } }
/** * This method checks, if GPU subsystem supports cross-device P2P access over PCIe. * * PLEASE NOTE: This method also returns TRUE if system has only one device. This is done to guarantee reallocation avoidance within same device. * * @return */ public boolean isP2PSupported() { return NativeOpsHolder.getInstance().getDeviceNativeOps().isP2PAvailable(); }
@Override public void deallocate() { NativeOpsHolder.getInstance().getDeviceNativeOps().freeDevice(Workspace.this, null); } });
protected void freeHost(Pointer pointer) { NativeOps nativeOps = NativeOpsHolder.getInstance().getDeviceNativeOps(); nativeOps.freeHost(pointer); }
@Override public void run() { while (true) { try { GarbageStateReference reference = (GarbageStateReference) queue.remove(); if (reference != null) { if (reference.getStatePointer() != null) { referenceMap.remove(reference.getStatePointer().address()); NativeOpsHolder.getInstance().getDeviceNativeOps() .destroyRandom(reference.getStatePointer()); } } else { LockSupport.parkNanos(5000L); } } catch (InterruptedException e) { // do nothing } catch (Exception e) { throw new RuntimeException(e); } } } }
Pointer res = NativeOpsHolder.getInstance().getDeviceNativeOps().executeFlatGraphFloat(null, bPtr); if (res == null) throw new ND4JIllegalStateException("Graph execution failed");
public NativeRandom(long seed, long numberOfElements) { this.amplifier = seed; this.generation = 1; this.seed = seed; this.numberOfElements = numberOfElements; nativeOps = NativeOpsHolder.getInstance().getDeviceNativeOps(); stateBuffer = Nd4j.getDataBufferFactory().createDouble(numberOfElements); init(); hostPointer = new LongPointer(stateBuffer.addressPointer()); deallocator = NativeRandomDeallocator.getInstance(); pack = new NativePack(statePointer.address(), statePointer); deallocator.trackStatePointer(pack); }
private NativeOpsHolder() { try { Properties props = Nd4jContext.getInstance().getConf(); String name = System.getProperty(Nd4j.NATIVE_OPS, props.get(Nd4j.NATIVE_OPS).toString()); Class<? extends NativeOps> nativeOpsClazz = Class.forName(name).asSubclass(NativeOps.class); deviceNativeOps = nativeOpsClazz.newInstance(); deviceNativeOps.initializeDevicesAndFunctions(); int numThreads; String numThreadsString = System.getenv("OMP_NUM_THREADS"); if (numThreadsString != null && !numThreadsString.isEmpty()) { numThreads = Integer.parseInt(numThreadsString); deviceNativeOps.setOmpNumThreads(numThreads); } else { int cores = Loader.totalCores(); int chips = Loader.totalChips(); if (chips > 0 && cores > 0) { deviceNativeOps.setOmpNumThreads(Math.max(1, cores / chips)); } else deviceNativeOps.setOmpNumThreads( deviceNativeOps.getCores(Runtime.getRuntime().availableProcessors())); } //deviceNativeOps.setOmpNumThreads(4); log.info("Number of threads used for NativeOps: {}", deviceNativeOps.ompGetMaxThreads()); } catch (Exception | Error e) { throw new RuntimeException( "ND4J is probably missing dependencies. For more information, please refer to: http://nd4j.org/getstarted.html", e); } }
@Override public void reSeed(long amplifier) { this.amplifier = amplifier; nativeOps.reSeedBuffer(getExtraPointers(), amplifier, getStatePointer()); }
/** * Returns the BLAS library vendor * * @return the BLAS library vendor */ @Override public Vendor getBlasVendor() { int vendor = getBlasVendorId(); boolean isUnknowVendor = ((vendor > Vendor.values().length - 1) || (vendor <= 0)); if (isUnknowVendor) { return Vendor.UNKNOWN; } return Vendor.values()[vendor]; } }
/** * Returns the BLAS library vendor * * @return the BLAS library vendor */ @Override public Vendor getBlasVendor() { int vendor = getBlasVendorId(); boolean isUnknowVendor = ((vendor > Vendor.values().length - 1) || (vendor <= 0)); if (isUnknowVendor) { return Vendor.UNKNOWN; } return Vendor.values()[vendor]; } }
/** * This method checks, if GPU subsystem supports cross-device P2P access over PCIe. * * PLEASE NOTE: This method also returns TRUE if system has only one device. This is done to guarantee reallocation avoidance within same device. * * @return */ public boolean isP2PSupported() { return NativeOpsHolder.getInstance().getDeviceNativeOps().isP2PAvailable(); }
@Override public void deallocate() { NativeOpsHolder.getInstance().getDeviceNativeOps().freeDevice(Workspace.this, null); } });
protected void freeHost(Pointer pointer) { NativeOps nativeOps = NativeOpsHolder.getInstance().getDeviceNativeOps(); nativeOps.freeHost(pointer); }