Search in sources :

Example 11 with Worker

use of com.tencent.angel.worker.Worker in project angel by Tencent.

the class IndexGetRowsHashTest method testSparseIntUDF.

public void testSparseIntUDF() throws Exception {
    Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
    MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_INT_MAT, 0);
    int matrixW1Id = client1.getMatrixId();
    int[] index = genIndexs(feaNum, nnz);
    IntIntVector deltaVec = null;
    for (int rowId = 0; rowId < rowNum; rowId++) {
        deltaVec = new IntIntVector(feaNum, new IntIntSparseVectorStorage(feaNum));
        for (int i = 0; i < index.length; i++) {
            deltaVec.set(index[i], index[i]);
        }
        client1.increment(rowId, deltaVec, true);
    }
    int[] rowIds = new int[rowNum];
    for (int i = 0; i < rowNum; i++) {
        rowIds[i] = i;
    }
    Vector[] rows = client1.get(rowIds, index);
    for (int i = 0; i < rowNum; i++) {
        for (int id : index) {
            Assert.assertEquals(((IntIntVector) rows[i]).get(id), deltaVec.get(id), zero);
        }
        Assert.assertTrue(index.length == ((IntIntVector) rows[i]).size());
    }
}
Also used : Worker(com.tencent.angel.worker.Worker) MatrixClient(com.tencent.angel.psagent.matrix.MatrixClient)

Example 12 with Worker

use of com.tencent.angel.worker.Worker in project angel by Tencent.

the class IndexGetRowsHashTest method testDenseIntUDF.

public void testDenseIntUDF() throws Exception {
    Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
    MatrixClient client1 = worker.getPSAgent().getMatrixClient(DENSE_INT_MAT, 0);
    int matrixW1Id = client1.getMatrixId();
    int[] index = genIndexs(feaNum, nnz);
    IntIntVector deltaVec = null;
    for (int rowId = 0; rowId < rowNum; rowId++) {
        deltaVec = new IntIntVector(feaNum, new IntIntDenseVectorStorage(feaNum));
        for (int i = 0; i < feaNum; i++) deltaVec.set(i, i);
        client1.increment(rowId, deltaVec, true);
    }
    int[] rowIds = new int[rowNum];
    for (int i = 0; i < rowNum; i++) {
        rowIds[i] = i;
    }
    Vector[] rows = client1.get(rowIds, index);
    for (int i = 0; i < rowNum; i++) {
        for (int id : index) {
            Assert.assertEquals(((IntIntVector) rows[i]).get(id), deltaVec.get(id), zero);
        }
    }
}
Also used : Worker(com.tencent.angel.worker.Worker) MatrixClient(com.tencent.angel.psagent.matrix.MatrixClient)

Example 13 with Worker

use of com.tencent.angel.worker.Worker in project angel by Tencent.

the class PSAgentTest method testTaskContext.

@Test
public void testTaskContext() throws Exception {
    try {
        AngelApplicationMaster angelAppMaster = LocalClusterContext.get().getMaster().getAppMaster();
        assertTrue(angelAppMaster != null);
        AMTaskManager taskManager = angelAppMaster.getAppContext().getTaskManager();
        assertTrue(taskManager != null);
        WorkerManager workerManager = angelAppMaster.getAppContext().getWorkerManager();
        assertTrue(workerManager != null);
        Worker worker = LocalClusterContext.get().getWorker(worker0Attempt0Id).getWorker();
        assertTrue(worker != null);
        PSAgent psAgent = worker.getPSAgent();
        assertTrue(psAgent != null);
        PSAgentContext psAgentContext = PSAgentContext.get();
        assertTrue(psAgentContext.getPsAgent() != null);
        TaskContext taskContext1 = psAgentContext.getTaskContext(1);
        TaskContext taskContext2 = psAgentContext.getTaskContext(2);
        assertTrue(taskContext1 != null);
        assertTrue(taskContext2 != null);
        assertEquals(taskContext1.getIndex(), 1);
        assertEquals(taskContext2.getIndex(), 2);
        assertEquals(taskContext1.getEpoch(), 0);
        assertEquals(taskContext2.getEpoch(), 0);
        assertEquals(taskContext1.getProgress(), 0.0, 1e-5);
        assertEquals(taskContext2.getProgress(), 0.0, 1e-5);
    } catch (Exception x) {
        LOG.error("run testTaskContext failed ", x);
        throw x;
    }
}
Also used : WorkerManager(com.tencent.angel.master.worker.WorkerManager) AMTaskManager(com.tencent.angel.master.task.AMTaskManager) TaskContext(com.tencent.angel.psagent.task.TaskContext) AngelApplicationMaster(com.tencent.angel.master.AngelApplicationMaster) Worker(com.tencent.angel.worker.Worker) Test(org.junit.Test)

Example 14 with Worker

use of com.tencent.angel.worker.Worker in project angel by Tencent.

the class PSAgentTest method testPSAgentContext.

@Test
public void testPSAgentContext() throws Exception {
    try {
        AngelApplicationMaster angelAppMaster = LocalClusterContext.get().getMaster().getAppMaster();
        assertTrue(angelAppMaster != null);
        AMTaskManager taskManager = angelAppMaster.getAppContext().getTaskManager();
        assertTrue(taskManager != null);
        WorkerManager workerManager = angelAppMaster.getAppContext().getWorkerManager();
        assertTrue(workerManager != null);
        Worker worker = LocalClusterContext.get().getWorker(worker0Attempt0Id).getWorker();
        assertTrue(worker != null);
        PSAgent psAgent = worker.getPSAgent();
        assertTrue(psAgent != null);
        PSAgentContext psAgentContext = PSAgentContext.get();
        assertTrue(psAgentContext.getPsAgent() != null);
        assertTrue(psAgentContext.getConf() != null);
        assertTrue(psAgentContext.getMetrics() != null);
        assertTrue(psAgentContext.getMasterClient() != null);
        // assertTrue(psAgentContext.getOpLogCache() != null);
        assertTrue(psAgentContext.getMatrixTransportClient() != null);
        assertTrue(psAgentContext.getMatrixMetaManager() != null);
        assertTrue(psAgentContext.getMatrixMetaManager() != null);
        assertTrue(psAgentContext.getLocationManager() != null);
        assertEquals(psAgentContext.getRunningMode(), psAgent.getRunningMode());
        assertEquals(psAgentContext.getIp(), psAgent.getIp());
        assertEquals(psAgentContext.getStaleness(), psAgent.getConf().getInt(AngelConf.ANGEL_STALENESS, AngelConf.DEFAULT_ANGEL_STALENESS));
        assertEquals(psAgentContext.getMatrixStorageManager(), psAgent.getMatrixStorageManager());
        assertEquals(psAgentContext.getUserRequestAdapter(), psAgent.getUserRequestAdapter());
        assertEquals(psAgentContext.getExecutor(), psAgent.getExecutor());
        assertTrue(psAgentContext.getTaskContext(1) != null);
        assertTrue(psAgentContext.getTaskContext(2) != null);
        int taskNum = psAgentContext.getTotalTaskNum();
        assertEquals(taskNum, 2);
        int localTaskNum = psAgentContext.getLocalTaskNum();
        assertEquals(localTaskNum, 2);
    } catch (Exception x) {
        LOG.error("run testPSAgentContext failed ", x);
        throw x;
    }
}
Also used : WorkerManager(com.tencent.angel.master.worker.WorkerManager) AMTaskManager(com.tencent.angel.master.task.AMTaskManager) AngelApplicationMaster(com.tencent.angel.master.AngelApplicationMaster) Worker(com.tencent.angel.worker.Worker) Test(org.junit.Test)

Example 15 with Worker

use of com.tencent.angel.worker.Worker in project angel by Tencent.

the class PSAgentTest method testClockCache.

@Test
public void testClockCache() throws Exception {
    try {
        AngelApplicationMaster angelAppMaster = LocalClusterContext.get().getMaster().getAppMaster();
        assertTrue(angelAppMaster != null);
        AMTaskManager taskManager = angelAppMaster.getAppContext().getTaskManager();
        assertTrue(taskManager != null);
        WorkerManager workerManager = angelAppMaster.getAppContext().getWorkerManager();
        assertTrue(workerManager != null);
        Worker worker = LocalClusterContext.get().getWorker(worker0Attempt0Id).getWorker();
        assertTrue(worker != null);
        PSAgent psAgent = worker.getPSAgent();
        assertTrue(psAgent != null);
    } catch (Exception x) {
        LOG.error("run testClockCache failed ", x);
        throw x;
    }
}
Also used : WorkerManager(com.tencent.angel.master.worker.WorkerManager) AMTaskManager(com.tencent.angel.master.task.AMTaskManager) AngelApplicationMaster(com.tencent.angel.master.AngelApplicationMaster) Worker(com.tencent.angel.worker.Worker) Test(org.junit.Test)

Aggregations

Worker (com.tencent.angel.worker.Worker)196 MatrixClient (com.tencent.angel.psagent.matrix.MatrixClient)183 Test (org.junit.Test)21 AMTaskManager (com.tencent.angel.master.task.AMTaskManager)13 IntDoubleVector (com.tencent.angel.ml.math2.vector.IntDoubleVector)13 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)13 IntIntVector (com.tencent.angel.ml.math2.vector.IntIntVector)13 IntLongVector (com.tencent.angel.ml.math2.vector.IntLongVector)12 LongDoubleVector (com.tencent.angel.ml.math2.vector.LongDoubleVector)12 LongFloatVector (com.tencent.angel.ml.math2.vector.LongFloatVector)12 LongIntVector (com.tencent.angel.ml.math2.vector.LongIntVector)12 LongLongVector (com.tencent.angel.ml.math2.vector.LongLongVector)12 Vector (com.tencent.angel.ml.math2.vector.Vector)12 IncrementRows (com.tencent.angel.ml.matrix.psf.update.update.IncrementRows)12 IncrementRowsParam (com.tencent.angel.ml.matrix.psf.update.update.IncrementRowsParam)12 WorkerManager (com.tencent.angel.master.worker.WorkerManager)10 Location (com.tencent.angel.common.location.Location)9 AngelApplicationMaster (com.tencent.angel.master.AngelApplicationMaster)9 LongIndexGet (com.tencent.angel.ml.matrix.psf.get.indexed.LongIndexGet)8 LongIndexGetParam (com.tencent.angel.ml.matrix.psf.get.indexed.LongIndexGetParam)8