Search in sources :

Example 1 with Configuration

use of org.nd4j.jita.conf.Configuration in project nd4j by deeplearning4j.

the class AsynchronousFlowControllerTest method testDependencies4.

@Test
public void testDependencies4() throws Exception {
    INDArray arrayWrite = Nd4j.create(new float[] { 1f, 2f, 3f });
    INDArray array = Nd4j.create(new float[] { 1f, 2f, 3f });
    // we use synchronization to make sure it completes activeWrite caused by array creation
    String arrayContents = array.toString();
    AllocationPoint point = allocator.getAllocationPoint(array);
    AllocationPoint pointWrite = allocator.getAllocationPoint(arrayWrite);
    assertPointHasNoDependencies(point);
    controller.cutTail();
    CudaContext context = controller.prepareAction(arrayWrite, array);
    controller.registerAction(context, arrayWrite, array);
    assertTrue(controller.hasActiveReads(point));
    assertFalse(controller.hasActiveReads(pointWrite));
    assertNotEquals(-1, controller.hasActiveWrite(pointWrite));
    Configuration configuration = CudaEnvironment.getInstance().getConfiguration();
    controller.sweepTail();
    assertTrue(controller.hasActiveReads(point));
    assertFalse(controller.hasActiveReads(pointWrite));
    assertNotEquals(-1, controller.hasActiveWrite(pointWrite));
    controller.sweepTail();
    assertTrue(controller.hasActiveReads(point));
    assertFalse(controller.hasActiveReads(pointWrite));
    assertNotEquals(-1, controller.hasActiveWrite(pointWrite));
    for (int i = 0; i < configuration.getCommandQueueLength(); i++) controller.sweepTail();
    assertPointHasNoDependencies(point);
    assertPointHasNoDependencies(pointWrite);
}
Also used : INDArray(org.nd4j.linalg.api.ndarray.INDArray) Configuration(org.nd4j.jita.conf.Configuration) CudaContext(org.nd4j.linalg.jcublas.context.CudaContext) AllocationPoint(org.nd4j.jita.allocator.impl.AllocationPoint) AllocationPoint(org.nd4j.jita.allocator.impl.AllocationPoint) Test(org.junit.Test)

Example 2 with Configuration

use of org.nd4j.jita.conf.Configuration in project nd4j by deeplearning4j.

the class AtomicAllocatorTest method setUp.

@Before
public void setUp() throws Exception {
    DataTypeUtil.setDTypeForContext(DataBuffer.Type.FLOAT);
    if (allocator == null) {
        Configuration configuration = new Configuration();
        // configuration.setHostDeallocAggressiveness(Aggressiveness.IMMEDIATE);
        configuration.setMaximumSingleHostAllocation(5000);
        configuration.setMaximumZeroAllocation(1000000000);
        // singleDevice4GBcc52 = new CudaEnvironment(configuration);
        DeviceInformation device1 = new DeviceInformation();
        device1.setDeviceId(0);
        device1.setCcMajor(5);
        device1.setCcMinor(2);
        device1.setTotalMemory(4 * 1024 * 1024 * 1024L);
        device1.setAvailableMemory(4 * 1024 * 1024 * 1024L);
        // singleDevice4GBcc52.addDevice(device1);
        allocator = AtomicAllocator.getInstance();
    // allocator.applyConfiguration(configuration);
    // allocator.setEnvironment(singleDevice4GBcc52);
    // allocator.setMemoryHandler(new CudaZeroHandler());
    }
}
Also used : Configuration(org.nd4j.jita.conf.Configuration) DeviceInformation(org.nd4j.jita.conf.DeviceInformation) Before(org.junit.Before)

Aggregations

Configuration (org.nd4j.jita.conf.Configuration)2 Before (org.junit.Before)1 Test (org.junit.Test)1 AllocationPoint (org.nd4j.jita.allocator.impl.AllocationPoint)1 DeviceInformation (org.nd4j.jita.conf.DeviceInformation)1 INDArray (org.nd4j.linalg.api.ndarray.INDArray)1 CudaContext (org.nd4j.linalg.jcublas.context.CudaContext)1