Generate memory/system report as a String, for the specified network.
Includes informatioun about the system, memory configuration, network, etc.

@param net   Net to generate the report for
@return Report as a String
340505
public static String generateMemoryStatus(Model net, int minibatch, InputType... inputTypes){
        MultiLayerNetwork mln = null;
        ComputationGraph cg = null;
        boolean isMLN;
        if(net instanceof MultiLayerNetwork){
            mln = (MultiLayerNetwork)net;
            isMLN = true;
        } else {
            cg = (ComputationGraph)net;
            isMLN = false;
        }

        StringBuilder sb = genericMemoryStatus();

        int bytesPerElement;
        switch (Nd4j.dataType()){
            case DOUBLE:
                bytesPerElement = 8;
                break;
            case FLOAT:
                bytesPerElement = 4;
                break;
            case HALF:
                bytesPerElement = 2;
                break;
            default:
                bytesPerElement = 0;    //TODO
        }

        sb.append("\n----- Workspace Information -----\n");
        List<MemoryWorkspace> allWs = Nd4j.getWorkspaceManager().getAllWorkspacesForCurrentThread();
        sb.append(f("Workspaces: # for current thread", (allWs == null ? 0 : allWs.size())));
        //sb.append(f("Workspaces: # for all threads", allWs.size()));      //TODO
        long totalWsSize = 0;
        if(allWs != null && allWs.size() > 0) {
            sb.append("Current thread workspaces:\n");
            //Name, open, size, currently allocated
            String wsFormat = "  %-26s%-12s%-30s%-20s";
            sb.append(String.format(wsFormat, "Name", "State", "Size", "# Cycles")).append("\n");
            for (MemoryWorkspace ws : allWs) {
                totalWsSize += ws.getCurrentSize();
                long numCycles = ws.getGenerationId();
                sb.append(String.format(wsFormat, ws.getId(),
                        (ws.isScopeActive() ? "OPEN" : "CLOSED"),
                        fBytes(ws.getCurrentSize()),
                        String.valueOf(numCycles))).append("\n");
            }
        }
        sb.append(fBytes("Workspaces total size", totalWsSize));
        Map<String,Pointer> helperWorkspaces;
        if(isMLN){
            helperWorkspaces = mln.getHelperWorkspaces();
        } else {
            helperWorkspaces = cg.getHelperWorkspaces();
        }
        if(helperWorkspaces != null && !helperWorkspaces.isEmpty()){
            boolean header = false;
            for(Map.Entry<String,Pointer> e : helperWorkspaces.entrySet()){
                Pointer p = e.getValue();
                if(p == null){
                    continue;
                }
                if(!header){
                    sb.append("Helper Workspaces\n");
                    header = true;
                }
                sb.append("  ").append(fBytes(e.getKey(), p.capacity()));
            }
        }

        long sumMem = 0;
        long nParams = net.params().length();
        sb.append("\n----- Network Information -----\n")
                .append(f("Network # Parameters", nParams))
                .append(fBytes("Parameter Memory", bytesPerElement * nParams));
        INDArray flattenedGradients;
        if(isMLN){
            flattenedGradients = mln.getFlattenedGradients();
        } else {
            flattenedGradients = cg.getFlattenedGradients();
        }
        if(flattenedGradients == null){
            sb.append(f("Parameter Gradients Memory", "<not allocated>"));
        } else {
            sumMem += (flattenedGradients.length() * bytesPerElement);
            sb.append(fBytes("Parameter Gradients Memory", bytesPerElement * flattenedGradients.length()));
        }
            //Updater info
        BaseMultiLayerUpdater u;
        if(isMLN){
            u = (BaseMultiLayerUpdater)mln.getUpdater(false);
        } else {
            u = cg.getUpdater(false);
        }
        Set<String> updaterClasses = new HashSet<>();
        if(u == null){
            sb.append(f("Updater","<not initialized>"));
        } else {
            INDArray stateArr = u.getStateViewArray();
            long stateArrLength = (stateArr == null ? 0 : stateArr.length());
            sb.append(f("Updater Number of Elements", stateArrLength));
            sb.append(fBytes("Updater Memory", stateArrLength * bytesPerElement));
            sumMem += stateArrLength * bytesPerElement;

            List<UpdaterBlock> blocks = u.getUpdaterBlocks();
            for(UpdaterBlock ub : blocks){
                updaterClasses.add(ub.getGradientUpdater().getClass().getName());
            }

            sb.append("Updater Classes:").append("\n");
            for(String s : updaterClasses ){
                sb.append("  ").append(s).append("\n");
            }
        }
        sb.append(fBytes("Params + Gradient + Updater Memory", sumMem));
            //Iter/epoch
        sb.append(f("Iteration Count", BaseOptimizer.getIterationCount(net)));
        sb.append(f("Epoch Count", BaseOptimizer.getEpochCount(net)));

            //Workspaces, backprop type, layer info, activation info, helper info
        if(isMLN) {
            sb.append(f("Backprop Type", mln.getLayerWiseConfigurations().getBackpropType()));
            if(mln.getLayerWiseConfigurations().getBackpropType() == BackpropType.TruncatedBPTT){
                sb.append(f("TBPTT Length", mln.getLayerWiseConfigurations().getTbpttFwdLength() + "/" + mln.getLayerWiseConfigurations().getTbpttBackLength()));
            }
            sb.append(f("Workspace Mode: Training", mln.getLayerWiseConfigurations().getTrainingWorkspaceMode()));
            sb.append(f("Workspace Mode: Inference", mln.getLayerWiseConfigurations().getInferenceWorkspaceMode()));
            appendLayerInformation(sb, mln.getLayers(), bytesPerElement);
            appendHelperInformation(sb, mln.getLayers());
            appendActivationShapes(mln, (inputTypes == null || inputTypes.length == 0 ? null : inputTypes[0]), minibatch, sb, bytesPerElement);
        } else {
            sb.append(f("Backprop Type", cg.getConfiguration().getBackpropType()));
            if(cg.getConfiguration().getBackpropType() == BackpropType.TruncatedBPTT){
                sb.append(f("TBPTT Length", cg.getConfiguration().getTbpttFwdLength() + "/" + cg.getConfiguration().getTbpttBackLength()));
            }
            sb.append(f("Workspace Mode: Training", cg.getConfiguration().getTrainingWorkspaceMode()));
            sb.append(f("Workspace Mode: Inference", cg.getConfiguration().getInferenceWorkspaceMode()));
            appendLayerInformation(sb, cg.getLayers(), bytesPerElement);
            appendHelperInformation(sb, cg.getLayers());
            appendActivationShapes(cg, sb, bytesPerElement);
        }

        //Listener info:
        Collection<TrainingListener> listeners;
        if(isMLN){
            listeners = mln.getListeners();
        } else {
            listeners = cg.getListeners();
        }

        sb.append("\n----- Network Training Listeners -----\n");
        sb.append(f("Number of Listeners", (listeners == null ? 0 : listeners.size())));
        int lCount = 0;
        if(listeners != null && !listeners.isEmpty()){
            for(TrainingListener tl : listeners) {
                sb.append(f("Listener " + (lCount++), tl));
            }
        }
        
        return sb.toString();
    }
159738
private static String buildConnectionString(final String connectionString,
                                               final Config config) {

      if(config == null) {
         return connectionString;
      }

      StringBuilder buf = new StringBuilder();
      Iterator<Map.Entry<String, ConfigValue>> iter = config.entrySet().iterator();
      if(iter.hasNext()) {
         Map.Entry<String, ConfigValue> curr = iter.next();
         buf.append(curr.getKey()).append("=").append(curr.getValue().unwrapped().toString());
      } else {
         return connectionString;
      }

      while(iter.hasNext()) {
         Map.Entry<String, ConfigValue> curr = iter.next();
         buf.append("&").append(curr.getKey()).append("=").append(curr.getValue().unwrapped().toString());
      }

      if(connectionString.indexOf('?') > 0) {
         return connectionString + "&" + buf.toString();
      } else {
         return connectionString + "?" + buf.toString();
      }
   }
1195406
public static String memoryUsage() {
    final Runtime runtime = Runtime.getRuntime();

    runtime.gc();

    final long max = runtime.maxMemory();
    final long total = runtime.totalMemory();
    final long free = runtime.freeMemory();
    final long used = total - free;

    return String.format("%d\t%d\t%d\t%d", max, total, free, used);
  }
289819
@FFDCIgnore(InvalidNameException.class)
    public static String getCNFromDN(String dn) {
        String cn = null;
        try {
            LdapName ldapDN = new LdapName(dn);
            for (int i = ldapDN.size() - 1; i > -1; i--) {
                //for (int i = 0; i < ldapDN.size(); i++) {
                if (ldapDN.get(i).toLowerCase().startsWith("cn=")) {
                    cn = ldapDN.get(i).substring(START_CN_OFFSET);
                    break;
                }
            }
        } catch (InvalidNameException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Unable to getCNFromDN: " + e.getMessage(), e);
            }
        }
        return cn;
    }
427020
public static String stringFor(int n)
    {
        switch (n)
        {
            case CUDNN_CONVOLUTION_BWD_DATA_ALGO_0: return "CUDNN_CONVOLUTION_BWD_DATA_ALGO_0";
            case CUDNN_CONVOLUTION_BWD_DATA_ALGO_1: return "CUDNN_CONVOLUTION_BWD_DATA_ALGO_1";
            case CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT: return "CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT";
            case CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT_TILING: return "CUDNN_CONVOLUTION_BWD_DATA_ALGO_FFT_TILING";
            case CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD: return "CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD";
            case CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED: return "CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED";
            case CUDNN_CONVOLUTION_BWD_DATA_ALGO_COUNT: return "CUDNN_CONVOLUTION_BWD_DATA_ALGO_COUNT";
        }
        return "INVALID cudnnConvolutionBwdDataAlgo: "+n;
    }
1118715
public String generate(final int bad) {
		int[] sizes = new int[nodes.size()];
		for (int i = 0; i < sizes.length; i++) {
			Range r = nodes.get(i).getRange();
			sizes[i] = r.getMin() + r.getRange() / 2;
		}
		return generate(sizes, bad);
	}
646655
public static String stringFor(int n)
    {
        switch (n)
        {
            case CUDNN_CONVOLUTION_BWD_FILTER_ALGO_0: return "CUDNN_CONVOLUTION_BWD_FILTER_ALGO_0";
            case CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1: return "CUDNN_CONVOLUTION_BWD_FILTER_ALGO_1";
            case CUDNN_CONVOLUTION_BWD_FILTER_ALGO_FFT: return "CUDNN_CONVOLUTION_BWD_FILTER_ALGO_FFT";
            case CUDNN_CONVOLUTION_BWD_FILTER_ALGO_3: return "CUDNN_CONVOLUTION_BWD_FILTER_ALGO_3";
            case CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD: return "CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD";
            case CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD_NONFUSED: return "CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD_NONFUSED";
            case CUDNN_CONVOLUTION_BWD_FILTER_ALGO_FFT_TILING: return "CUDNN_CONVOLUTION_BWD_FILTER_ALGO_FFT_TILING";
            case CUDNN_CONVOLUTION_BWD_FILTER_ALGO_COUNT: return "CUDNN_CONVOLUTION_BWD_FILTER_ALGO_COUNT";
        }
        return "INVALID cudnnConvolutionBwdFilterAlgo: "+n;
    }
683470
public static String stringFor(int n)
    {
        switch (n)
        {
            case CUSOLVER_STATUS_SUCCESS: return "CUSOLVER_STATUS_SUCCESS";
            case CUSOLVER_STATUS_NOT_INITIALIZED: return "CUSOLVER_STATUS_NOT_INITIALIZED";
            case CUSOLVER_STATUS_ALLOC_FAILED: return "CUSOLVER_STATUS_ALLOC_FAILED";
            case CUSOLVER_STATUS_INVALID_VALUE: return "CUSOLVER_STATUS_INVALID_VALUE";
            case CUSOLVER_STATUS_ARCH_MISMATCH: return "CUSOLVER_STATUS_ARCH_MISMATCH";
            case CUSOLVER_STATUS_MAPPING_ERROR: return "CUSOLVER_STATUS_MAPPING_ERROR";
            case CUSOLVER_STATUS_EXECUTION_FAILED: return "CUSOLVER_STATUS_EXECUTION_FAILED";
            case CUSOLVER_STATUS_INTERNAL_ERROR: return "CUSOLVER_STATUS_INTERNAL_ERROR";
            case CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED: return "CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED";
            case CUSOLVER_STATUS_NOT_SUPPORTED: return "CUSOLVER_STATUS_NOT_SUPPORTED";
            case CUSOLVER_STATUS_ZERO_PIVOT: return "CUSOLVER_STATUS_ZERO_PIVOT";
            case CUSOLVER_STATUS_INVALID_LICENSE: return "CUSOLVER_STATUS_INVALID_LICENSE";
        }
        return "INVALID cusolverStatus: "+n;
    }
695206
public static String stringFor(int n)
    {
        switch (n)
        {
            case CU_RES_VIEW_FORMAT_NONE          : return"CU_RES_VIEW_FORMAT_NONE";
            case CU_RES_VIEW_FORMAT_UINT_1X8      : return"CU_RES_VIEW_FORMAT_UINT_1X8";
            case CU_RES_VIEW_FORMAT_UINT_2X8      : return"CU_RES_VIEW_FORMAT_UINT_2X8";
            case CU_RES_VIEW_FORMAT_UINT_4X8      : return"CU_RES_VIEW_FORMAT_UINT_4X8";
            case CU_RES_VIEW_FORMAT_SINT_1X8      : return"CU_RES_VIEW_FORMAT_SINT_1X8";
            case CU_RES_VIEW_FORMAT_SINT_2X8      : return"CU_RES_VIEW_FORMAT_SINT_2X8";
            case CU_RES_VIEW_FORMAT_SINT_4X8      : return"CU_RES_VIEW_FORMAT_SINT_4X8";
            case CU_RES_VIEW_FORMAT_UINT_1X16     : return"CU_RES_VIEW_FORMAT_UINT_1X16";
            case CU_RES_VIEW_FORMAT_UINT_2X16     : return"CU_RES_VIEW_FORMAT_UINT_2X16";
            case CU_RES_VIEW_FORMAT_UINT_4X16     : return"CU_RES_VIEW_FORMAT_UINT_4X16";
            case CU_RES_VIEW_FORMAT_SINT_1X16     : return"CU_RES_VIEW_FORMAT_SINT_1X16";
            case CU_RES_VIEW_FORMAT_SINT_2X16     : return"CU_RES_VIEW_FORMAT_SINT_2X16";
            case CU_RES_VIEW_FORMAT_SINT_4X16     : return"CU_RES_VIEW_FORMAT_SINT_4X16";
            case CU_RES_VIEW_FORMAT_UINT_1X32     : return"CU_RES_VIEW_FORMAT_UINT_1X32";
            case CU_RES_VIEW_FORMAT_UINT_2X32     : return"CU_RES_VIEW_FORMAT_UINT_2X32";
            case CU_RES_VIEW_FORMAT_UINT_4X32     : return"CU_RES_VIEW_FORMAT_UINT_4X32";
            case CU_RES_VIEW_FORMAT_SINT_1X32     : return"CU_RES_VIEW_FORMAT_SINT_1X32";
            case CU_RES_VIEW_FORMAT_SINT_2X32     : return"CU_RES_VIEW_FORMAT_SINT_2X32";
            case CU_RES_VIEW_FORMAT_SINT_4X32     : return"CU_RES_VIEW_FORMAT_SINT_4X32";
            case CU_RES_VIEW_FORMAT_FLOAT_1X16    : return"CU_RES_VIEW_FORMAT_FLOAT_1X16";
            case CU_RES_VIEW_FORMAT_FLOAT_2X16    : return"CU_RES_VIEW_FORMAT_FLOAT_2X16";
            case CU_RES_VIEW_FORMAT_FLOAT_4X16    : return"CU_RES_VIEW_FORMAT_FLOAT_4X16";
            case CU_RES_VIEW_FORMAT_FLOAT_1X32    : return"CU_RES_VIEW_FORMAT_FLOAT_1X32";
            case CU_RES_VIEW_FORMAT_FLOAT_2X32    : return"CU_RES_VIEW_FORMAT_FLOAT_2X32";
            case CU_RES_VIEW_FORMAT_FLOAT_4X32    : return"CU_RES_VIEW_FORMAT_FLOAT_4X32";
            case CU_RES_VIEW_FORMAT_UNSIGNED_BC1  : return"CU_RES_VIEW_FORMAT_UNSIGNED_BC1";
            case CU_RES_VIEW_FORMAT_UNSIGNED_BC2  : return"CU_RES_VIEW_FORMAT_UNSIGNED_BC2";
            case CU_RES_VIEW_FORMAT_UNSIGNED_BC3  : return"CU_RES_VIEW_FORMAT_UNSIGNED_BC3";
            case CU_RES_VIEW_FORMAT_UNSIGNED_BC4  : return"CU_RES_VIEW_FORMAT_UNSIGNED_BC4";
            case CU_RES_VIEW_FORMAT_SIGNED_BC4    : return"CU_RES_VIEW_FORMAT_SIGNED_BC4";
            case CU_RES_VIEW_FORMAT_UNSIGNED_BC5  : return"CU_RES_VIEW_FORMAT_UNSIGNED_BC5";
            case CU_RES_VIEW_FORMAT_SIGNED_BC5    : return"CU_RES_VIEW_FORMAT_SIGNED_BC5";
            case CU_RES_VIEW_FORMAT_UNSIGNED_BC6H : return"CU_RES_VIEW_FORMAT_UNSIGNED_BC6H";
            case CU_RES_VIEW_FORMAT_SIGNED_BC6H   : return"CU_RES_VIEW_FORMAT_SIGNED_BC6H";
            case CU_RES_VIEW_FORMAT_UNSIGNED_BC7  : return"CU_RES_VIEW_FORMAT_UNSIGNED_BC7";
        }
        return "INVALID CUresourceViewFormat: "+n;
    }
920111
public static String stringFor(int result)
    {
        switch (result)
        {
            case NVRTC_SUCCESS                                     : return "NVRTC_SUCCESS";
            case NVRTC_ERROR_OUT_OF_MEMORY                         : return "NVRTC_ERROR_OUT_OF_MEMORY";
            case NVRTC_ERROR_PROGRAM_CREATION_FAILURE              : return "NVRTC_ERROR_PROGRAM_CREATION_FAILURE";
            case NVRTC_ERROR_INVALID_INPUT                         : return "NVRTC_ERROR_INVALID_INPUT";
            case NVRTC_ERROR_INVALID_PROGRAM                       : return "NVRTC_ERROR_INVALID_PROGRAM";
            case NVRTC_ERROR_INVALID_OPTION                        : return "NVRTC_ERROR_INVALID_OPTION";
            case NVRTC_ERROR_COMPILATION                           : return "NVRTC_ERROR_COMPILATION";
            case NVRTC_ERROR_BUILTIN_OPERATION_FAILURE             : return "NVRTC_ERROR_BUILTIN_OPERATION_FAILURE";
            case NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION : return "NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION";
            case NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION   : return "NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION";
            case NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID             : return "NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID";
            case NVRTC_ERROR_INTERNAL_ERROR                        : return "NVRTC_ERROR_INTERNAL_ERROR";
            case JCUDA_INTERNAL_ERROR                              : return "JCUDA_INTERNAL_ERROR";
        }
        return "INVALID nvrtcResult: "+result;
    }
207588
public static String stringFor(int n)
    {
        if (n == 0)
        {
            return "CU_GRAPHICS_REGISTER_FLAGS_NONE";
        }
        String result = "";
        if ((n & CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY    ) != 0) result += "CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY ";
        if ((n & CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD) != 0) result += "CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD ";
        if ((n & CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST ) != 0) result += "CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST ";
        if ((n & CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER ) != 0) result += "CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER ";
        return result;
    }
629362
public static String stringFor(int n)
    {
        switch (n)
        {
            case CU_LIMIT_STACK_SIZE : return "CU_LIMIT_STACK_SIZE";
            case CU_LIMIT_PRINTF_FIFO_SIZE : return "CU_LIMIT_PRINTF_FIFO_SIZE";
            case CU_LIMIT_MALLOC_HEAP_SIZE : return "CU_LIMIT_MALLOC_HEAP_SIZE";
            case CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH : return "CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH";
            case CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT : return "CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT";
            case CU_LIMIT_MAX_L2_FETCH_GRANULARITY : return "CU_LIMIT_MAX_L2_FETCH_GRANULARITY";
        }
        return "INVALID CUlimit: "+n;
    }
1221279
public String dumpDatanode() {
    StringBuffer buffer = new StringBuffer();
    long c = getCapacity();
    long r = getRemaining();
    long u = getDfsUsed();
    buffer.append(name);
    if (!NetworkTopology.DEFAULT_RACK.equals(location)) {
      buffer.append(" "+location);
    }
    if (isDecommissioned()) {
      buffer.append(" DD");
    } else if (isDecommissionInProgress()) {
      buffer.append(" DP");
    } else {
      buffer.append(" IN");
    }
    buffer.append(" " + c + "(" + StringUtils.byteDesc(c)+")");
    buffer.append(" " + u + "(" + StringUtils.byteDesc(u)+")");
    buffer.append(" " + StringUtils.limitDecimalTo2(((1.0*u)/c)*100)+"%");
    buffer.append(" " + r + "(" + StringUtils.byteDesc(r)+")");
    buffer.append(" " + new Date(lastUpdate));
    return buffer.toString();
  }
850445
public static String dumpLocalNetworkInfo() throws UnknownHostException, SocketException {
        StringBuffer buffer = new StringBuffer();
        InetAddress addr = InetAddress.getLocalHost();
        buffer.append("Localhost: " + getAddrInfo(addr) + "\n");
        Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
        buffer.append("Network interfaces:\n");
        while (nifs.hasMoreElements()) {
            NetworkInterface nif = nifs.nextElement();
            buffer.append("  - " + getNetworkInterfaceInfo(nif) + "\n");
            Enumeration<InetAddress> addresses = nif.getInetAddresses();
            while (addresses.hasMoreElements()) {
                addr = addresses.nextElement();
                buffer.append("    " + getAddrInfo(addr) + "\n");
            }
        }
        return buffer.toString();
    }
92337
public static String stringFor(int n)
    {
        switch (n)
        {
            case cudaGraphicsRegisterFlagsNone: return "cudaGraphicsRegisterFlagsNone";
            case cudaGraphicsRegisterFlagsReadOnly: return "cudaGraphicsRegisterFlagsReadOnly";
            case cudaGraphicsRegisterFlagsWriteDiscard: return "cudaGraphicsRegisterFlagsWriteDiscard";
            case cudaGraphicsRegisterFlagsSurfaceLoadStore: return "cudaGraphicsRegisterFlagsSurfaceLoadStore";
            case cudaGraphicsRegisterFlagsTextureGather: return "cudaGraphicsRegisterFlagsTextureGather";
        }
        return "INVALID cudaGraphicsRegisterFlags: "+n;
    }
268551
public static JsonObject serialize(OutputPortContext context) {
    return serialize(context.uri(), context.output().instance().component().network());
  }
278414
public static byte[] s2n(String string) {
        if (string == null) {
            return null;
        }
        byte[] stringBytes = string.getBytes(UTF8);
        byte[] allBytes = new byte[stringBytes.length + 1];
        System.arraycopy(stringBytes, 0, allBytes, 0, stringBytes.length);
        return allBytes;
    }