Java Code Examples for org.nd4j.linalg.api.ops.performance.PerformanceTracker#getInstance()

The following examples show how to use org.nd4j.linalg.api.ops.performance.PerformanceTracker#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeOpExecutioner.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
/**
 * This method return set of key/value and
 * key/key/value objects,
 * describing current environment
 *
 * @return
 */
@Override
public Properties getEnvironmentInformation() {
    Properties properties = super.getEnvironmentInformation();
    properties.put(Nd4jEnvironment.BACKEND_KEY, "CPU");
    properties.put(Nd4jEnvironment.OMP_THREADS_KEY, loop.ompGetMaxThreads());
    properties.put(Nd4jEnvironment.BLAS_THREADS_KEY, Nd4j.factory().blas().getMaxThreads());
    properties.put(Nd4jEnvironment.BLAS_VENDOR_KEY, (Nd4j.factory().blas()).getBlasVendor().toString());
    properties.put(Nd4jEnvironment.HOST_FREE_MEMORY_KEY, Pointer.maxBytes() - Pointer.totalBytes());

    // fill bandwidth information
    /*
    Note: Environment information is logged as part of ND4J initialization... but PerformanceTracker required
    ND4J init to be completed before it can be initialized. Hence we can get a null PerformanceTracker when
    OpExecutioner.printEnvironmentInformation() is called as part of ND4J class initialization - even
    though PerformanceTracker.getInstance() refers to a static final field (as it may not yet be initialized)
     */
    if(PerformanceTracker.getInstance() != null) {
        properties.put(Nd4jEnvironment.MEMORY_BANDWIDTH_KEY, PerformanceTracker.getInstance().getCurrentBandwidth());
    }

    return properties;
}
 
Example 2
Source File: PerformanceTrackerTests.java    From nd4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testPerformanceTracker_1() {
    val perf = PerformanceTracker.getInstance();

    // 100 nanoseconds spent for 5000 bytes. result should be around 50000 bytes per microsecond
    val res = perf.addMemoryTransaction(0, 100, 5000);
    assertEquals(50000, res);
}
 
Example 3
Source File: PerformanceTrackerTests.java    From nd4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testPerformanceTracker_2() {
    val perf = PerformanceTracker.getInstance();

    // 10 nanoseconds spent for 5000 bytes. result should be around 500000 bytes per microsecond
    val res = perf.addMemoryTransaction(0, 10, 5000, MemcpyDirection.HOST_TO_HOST);
    assertEquals(500000, res);
}
 
Example 4
Source File: PerformanceTrackerTests.java    From nd4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testPerformanceTracker_3() {
    val perf = PerformanceTracker.getInstance();

    // 10000 nanoseconds spent for 5000 bytes. result should be around 500 bytes per microsecond
    val res = perf.addMemoryTransaction(0, 10000, 5000);
    assertEquals(500, res);
}
 
Example 5
Source File: PerformanceTrackerTests.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testPerformanceTracker_1() {
    val perf = PerformanceTracker.getInstance();

    // 100 nanoseconds spent for 5000 bytes. result should be around 50000 bytes per microsecond
    val res = perf.addMemoryTransaction(0, 100, 5000);
    assertEquals(50000, res);
}
 
Example 6
Source File: PerformanceTrackerTests.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testPerformanceTracker_2() {
    val perf = PerformanceTracker.getInstance();

    // 10 nanoseconds spent for 5000 bytes. result should be around 500000 bytes per microsecond
    val res = perf.addMemoryTransaction(0, 10, 5000, MemcpyDirection.HOST_TO_HOST);
    assertEquals(500000, res);
}
 
Example 7
Source File: PerformanceTrackerTests.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testPerformanceTracker_3() {
    val perf = PerformanceTracker.getInstance();

    // 10000 nanoseconds spent for 5000 bytes. result should be around 500 bytes per microsecond
    val res = perf.addMemoryTransaction(0, 10000, 5000);
    assertEquals(500, res);
}