Skip to content

Commit 2f6f188

Browse files
authored
Add profiling to flagcxTuner (flagos-ai#258)
1 parent a2b81b9 commit 2f6f188

8 files changed

Lines changed: 614 additions & 267 deletions

File tree

flagcx/adaptor/include/tuner.h

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -49,66 +49,12 @@ struct flagcxEnvConfigList {
4949
struct flagcxEnvConfig configList[FLAGCX_ENV_CONFIG_MAX_COUNT];
5050
};
5151

52-
struct flagcxTuner {
53-
// Name of the tuner
54-
const char *name;
55-
56-
// Initializes tuner states.
57-
// Inputs:
58-
// - nRanks: number of ranks in current communicator. Each communicator
59-
// initialize its own tuner.
60-
// - nNodes: number of nodes in current communicator.
61-
// - logFunction: a logFunction can be useful to integrate logging together
62-
// with FLAGCX core.
63-
// Outputs:
64-
// - context: tuner context object
65-
flagcxResult_t (*init)(size_t nRanks, size_t nNodes,
66-
flagcxDebugLogger_t logFunction, void **context);
67-
68-
// Gets number of candidate communicator env settings available from this
69-
// tuner. Inputs:
70-
// - context: tuner context object
71-
// Outputs:
72-
// - nCandidates: number of candidate communicator
73-
flagcxResult_t (*getCandidateNumber)(void *context, uint32_t *nCandidates);
74-
75-
// Set appropriate environment variables according to index, and return the
76-
// communicator tag. Note that all the env settings are set before returning
77-
// from this function. Only env of type FLAGCX_ENV_TYPE_CREATION will be set
78-
// in this function. Inputs:
79-
// - context: tuner context object
80-
// - index: index of candidate communicator, range [0, nCandidates)
81-
// Outputs:
82-
// - commTag: communicator tag for this particular candidate
83-
flagcxResult_t (*setCandidate)(void *context, uint32_t index,
84-
struct flagcxCommTag *commTag);
85-
86-
// Select the best communicator candidate for this collective.
87-
// All the env of type FLAGCX_ENV_TYPE_COLL and FLAGCX_ENV_TYPE_ONETIME if
88-
// necessary will be set before returning from this function. Inputs:
89-
// - context: tuner context object
90-
// - collType: collective type , e.g., allreduce, allgather…
91-
// - nBytes: collective size in bytes
92-
// - numPipeOps: number of operations in the group
93-
// - regBuff: If non-zero, register user buffer is used.
94-
// Outputs:
95-
// - commTag: communicator tag, used to select the underlying communicator.
96-
//
97-
// InOut:
98-
// - collCostTable: collective cost table. the caller is responsible for
99-
// allocating and
100-
// deallocating the memory
101-
//
102-
flagcxResult_t (*getCollInfo)(void *context, flagcxCommOp_t collType,
103-
size_t nBytes, int numPipeOps,
104-
float **collCostTable, int regBuff,
105-
struct flagcxCommTag *commTag);
106-
107-
// Terminates the tuner and cleans up any resources that the tuner allocated.
108-
flagcxResult_t (*destroy)(void *context);
52+
// Used to pair ProfilingStart()/ProfilingStop() calls
53+
#define FLAGCX_PROFILE_KEY_MAX_LENGTH 64 // max length of profiling key string
54+
struct flagcxProfileKey {
55+
char key[FLAGCX_PROFILE_KEY_MAX_LENGTH]; // profiling key string
10956
};
11057

111-
typedef struct flagcxTuner flagcxTuner_t;
11258
#ifdef __cplusplus
11359
} // end extern "C"
11460
#endif

flagcx/core/comm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "flagcx_net.h"
1313
#include "info.h"
1414
#include "register.h"
15-
#include "tuner.h" // adaptor/include/tuner.h
15+
#include "flagcx_tuner.h"
1616
#include "type.h"
1717
#include <stdint.h>
1818

0 commit comments

Comments
 (0)