1_mpi_init.cpp 1.64 KB
Newer Older
lishen's avatar
lishen committed
1
2
3
4
5
6
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "mpi.h"
#include "net.h"
7
8
#include "bootstrap.h"
#include "hardware_utils.h"
lishen's avatar
lishen committed
9
10
11
12
13
14
15
16
17
18
19
20

using namespace sccl;

int main(int argc, char* argv[]) {
    int rank, nranks;

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &nranks);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);

    printf("rank=%d, nranks=%d\n", rank, nranks);

21
    // // ----------------------------------------------------------------------- //
lishen's avatar
lishen committed
22

23
24
25
    // INFO(SCCL_LOG_TOPO, "Bootstrap ...\n");
    // scclRankInfo_t* rank_info;
    // struct sccl::hardware::topology::bootstrap::BootstrapComm* comm;
lishen's avatar
lishen committed
26

27
28
    // SCCLCHECK(scclCalloc(&rank_info, 1));
    // SCCLCHECK(scclCalloc(&comm, 1));
29

30
31
32
33
    // rank_info->rank       = rank;
    // rank_info->nRanks     = nranks;
    // rank_info->localRanks = 2;
    // rank_info->hipDev     = rank % rank_info->localRanks;
34

35
36
    // auto sccl_bootstrap = new sccl::hardware::topology::bootstrap::Bootstrap(rank_info, comm);
    // SCCLCHECK(sccl_bootstrap->bootstrapInitCheck());
37

38
    // sccl::hardware::topology::bootstrap::printUniqueInfo(comm->unique_info);
39

40
41
42
    // int cuda_id;
    // HIPCHECK(hipGetDevice(&cuda_id));
    // printf("rank=%d, cuda_id=%d\n", rank, cuda_id);
lishen's avatar
lishen committed
43
44
45
46
47
48

    MPI_Finalize();
}

/*
单机执行
49
50
SCCL_DEBUG_LEVEL=ABORT mpirun --allow-run-as-root -np 4 1_mpi_init
SCCL_DEBUG_LEVEL=INFO SCCL_DEBUG_SUBSYS=ALL mpirun --allow-run-as-root -np 2 1_mpi_init
lishen's avatar
lishen committed
51
52

跨机执行
53
54
SCCL_DEBUG_LEVEL=ABORT mpirun --allow-run-as-root --hostfile hostfile -np 16 ./1_mpi_init
SCCL_DEBUG_LEVEL=ABORT SCCL_DEBUG_SUBSYS=BOOTSTRAP mpirun --allow-run-as-root --hostfile hostfile2 -np 4 ./1_mpi_init
lishen's avatar
lishen committed
55
*/