This method is used to allocate
@param context
@param deviceId
176084
protected void getDeviceBuffers(CudaContext context, int deviceId) {
        NativeOps nativeOps = NativeOpsHolder.getInstance().getDeviceNativeOps(); //((CudaExecutioner) Nd4j.getExecutioner()).getNativeOps();

        // we hardcode sizeOf to sizeOf(double)
        int sizeOf = 8;

        val reductionPointer = nativeOps.mallocDevice(16384 * sizeOf, deviceId, 0);
        if (reductionPointer == null)
            throw new IllegalStateException("Can't allocate [DEVICE] reduction buffer memory!");

        nativeOps.memsetAsync(reductionPointer, 0, 16384 * sizeOf, 0, context.getOldStream());

        context.syncOldStream();

        val allocationPointer = nativeOps.mallocDevice(16384 * sizeOf, deviceId, 0);
        if (allocationPointer == null)
            throw new IllegalStateException("Can't allocate [DEVICE] allocation buffer memory!");

        val scalarPointer = nativeOps.mallocHost(sizeOf, 0);
        if (scalarPointer == null)
            throw new IllegalStateException("Can't allocate [HOST] scalar buffer memory!");

        context.setBufferScalar(scalarPointer);
        context.setBufferAllocation(allocationPointer);
        context.setBufferReduction(reductionPointer);

        val specialPointer = nativeOps.mallocDevice(16384 * sizeOf, deviceId, 0);
        if (specialPointer == null)
            throw new IllegalStateException("Can't allocate [DEVICE] special buffer memory!");

        nativeOps.memsetAsync(specialPointer, 0, 16384 * sizeOf, 0, context.getOldStream());

        context.setBufferSpecial(specialPointer);
    }
535960
public long getPreciseFreeMemory(int deviceId) {
        // we refresh free memory on device
        val extFree = NativeOpsHolder.getInstance().getDeviceNativeOps().getDeviceFreeMemory(deviceId);
        //freePerDevice.get(deviceId).set(extFree);

        return extFree;
    }
1022136
public void setDevices(java.util.Collection<DeviceData> devices) {
        if (devices == null) {
            this.devices = null;
            return;
        }

        this.devices = new java.util.ArrayList<DeviceData>(devices);
    }
974646
@Override
    public void init(@NonNull Configuration configuration, @NonNull Allocator allocator) {
        this.configuration = configuration;

        this.deviceMemoryTracker = new DeviceAllocationsTracker(this.configuration);
        this.flowController.init(allocator);
    }
586962
public void insert(final DeviceData deviceData, final DevVarDoubleStringArray argin) {
        DevVarDoubleStringArrayHelper.insert(deviceData.getAny(), argin);
    }
859799
@Override
    public Set<Long> getDeviceTrackingPoints(Integer deviceId) {
        return deviceAllocations.get(deviceId).keySet();
    }
617225
public void setHandler(String contextId, Runnable action) {

        if (contextId != null) {
            m_createFunctions.put(contextId, action);
        }
    }
840956
@SuppressLint("HardwareIds")
  public static String getDeviceId(Context context) {
    String androidId = getString(context.getContentResolver(), ANDROID_ID);
    if (!isNullOrEmpty(androidId)
        && !"9774d56d682e549c".equals(androidId)
        && !"unknown".equals(androidId)
        && !"000000000000000".equals(androidId)) {
      return androidId;
    }

    // Serial number, guaranteed to be on all non phones in 2.3+.
    if (!isNullOrEmpty(Build.SERIAL)) {
      return Build.SERIAL;
    }

    // Telephony ID, guaranteed to be on all phones, requires READ_PHONE_STATE permission
    if (hasPermission(context, READ_PHONE_STATE) && hasFeature(context, FEATURE_TELEPHONY)) {
      TelephonyManager telephonyManager = getSystemService(context, TELEPHONY_SERVICE);
      @SuppressLint("MissingPermission")
      String telephonyId = telephonyManager.getDeviceId();
      if (!isNullOrEmpty(telephonyId)) {
        return telephonyId;
      }
    }

    // If this still fails, generate random identifier that does not persist across installations
    return UUID.randomUUID().toString();
  }
560994
public void set(int deviceId, T object) {
        try {
            locksMap.get(deviceId).writeLock().lock();
            backingMap.put(deviceId, object);
        } finally {
            locksMap.get(deviceId).writeLock().unlock();
        }
    }
1105539
@Override
    public void attachThreadToDevice(Thread thread, Integer deviceId) {
        attachThreadToDevice(thread.getId(), deviceId);
    }
752152
public void setDevices(java.util.Collection<DeviceDescription> devices) {
        if (devices == null) {
            this.devices = null;
            return;
        }

        this.devices = new java.util.ArrayList<DeviceDescription>(devices);
    }
861273
private void fillResponseContext(UnitResponse.Context context) {
        context.setDestinationNodeId(unitRequest.getContext().getSourceNodeId());
        context.setSourceNodeId(LocalNodeManager.LOCAL_NODE_ID);
        context.setMsgId(unitRequest.getContext().getMsgId());
        context.setSsid(unitRequest.getContext().getSsid());
    }
535468
static DeviceInfo initialize(Context context) {
        if (thisInstance_ == null) {
            thisInstance_ = new DeviceInfo(context);
        }
        return thisInstance_;
    }
395866
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
    public static String generateDeviceId(@NonNull Context context) {

        String deviceId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);

        if (TextUtils.isEmpty(deviceId)) {
            deviceId = getMacAddress(context);
        }

        if (TextUtils.isEmpty(deviceId)) {
            try {
                deviceId = FirebaseInstanceId.getInstance().getId();
            } catch (IllegalStateException e) {
                //Continue.
            }
        }

        if (TextUtils.isEmpty(deviceId)) {
            deviceId = UUID.randomUUID().toString();
        }

        return deviceId;
    }
1286294
@Override
    public void purgeDeviceObject(Long threadId, Integer deviceId, Long objectId, AllocationPoint point,
                    boolean copyback) {
        if (point.getAllocationStatus() != AllocationStatus.DEVICE)
            return;

        flowController.waitTillReleased(point);

        free(point, AllocationStatus.DEVICE);

        if (!deviceAllocations.get(deviceId).containsKey(objectId))
            throw new IllegalStateException("Can't happen ever");

        forget(point, AllocationStatus.DEVICE);

        if (deviceAllocations.get(deviceId).containsKey(objectId))
            throw new IllegalStateException("Can't happen ever");

        deviceMemoryTracker.subFromAllocation(threadId, deviceId, AllocationUtils.getRequiredMemory(point.getShape()));

        point.setAllocationStatus(AllocationStatus.HOST);

        //environment.trackAllocatedMemory(deviceId, AllocationUtils.getRequiredMemory(point.getShape()));
    }
809331
function setCachedMountContext(blockchain_id, datastore_context) {

   let userData = getUserData();
   if (!userData.datastore_contexts) {
      userData.datastore_contexts = {};
   }

   userData.datastore_contexts[blockchain_id] = datastore_context;
   setUserData(userData);
}
486152
public void createUISharedContext(Context context) {
		if (session != null) {
			uiContexts.put(context.getIndex(), context.duplicate());
		}
	}