Skip to content

Commit 3557d1a

Browse files
authored
Fix ASAN compile errors (#206)
* rocr/hsakmt: Fix asan compile errors - kfd context * rocr/hsakmt: Fix asan compile errors - KFDQMTest
1 parent 6a51de4 commit 3557d1a

5 files changed

Lines changed: 22 additions & 20 deletions

File tree

projects/rocr-runtime/libhsakmt/include/hsakmt/hsakmttypes.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,23 +1518,6 @@ typedef enum _HsaAisFlags {
15181518
HSA_AIS_WRITE= 0x2
15191519
} HsaAisFlags;
15201520

1521-
/*
1522-
* HsaKFDContext
1523-
*
1524-
* Represents the execution context for a connection to the Kernel Fusion Driver (KFD).
1525-
*
1526-
* This structure encapsulates all state required to manage a KFD session, including:
1527-
* - The file descriptor associated with the open KFD device
1528-
* - Related resources tied to this file descriptor
1529-
*
1530-
* Multiple HsaKFDContext instances can coexist simultaneously, each maintaining its own
1531-
* independent set of resources. These contexts are fully isolated from one another and
1532-
* must not have their resources mixed. For example, memory resources created in
1533-
* context A cannot be used in context B directly. If resources need to be shared between
1534-
* contexts, they must be explicitly exported and imported using the appropriate APIs.
1535-
*/
1536-
typedef struct _HsaKFDContext HsaKFDContext;
1537-
15381521
#pragma pack(pop, hsakmttypes_h)
15391522

15401523

projects/rocr-runtime/libhsakmt/src/fmm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ static manageable_aperture_t *fmm_get_aperture(struct hsa_kfd_fmm_context *fmm_c
10011001
}
10021002
}
10031003

1004-
static manageable_aperture_t *fmm_is_scratch_aperture(struct hsa_kfd_fmm_context *fmm_ctx, const void *address)
1004+
static gpu_mem_t *fmm_is_scratch_aperture(struct hsa_kfd_fmm_context *fmm_ctx, const void *address)
10051005
{
10061006
uint32_t i;
10071007

projects/rocr-runtime/libhsakmt/src/kfdcontext.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "kfdcontext.h"
88
#include "libhsakmt.h"
9+
#include <stdlib.h>
910
#include <stddef.h>
1011
#include <assert.h>
1112
#include <stdio.h>

projects/rocr-runtime/libhsakmt/src/kfdcontext.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ struct hsa_kfd_queue_context;
1313
struct hsa_kfd_fmm_context;
1414
struct hsa_kfd_event_context;
1515

16+
/*
17+
* HsaKFDContext
18+
*
19+
* Represents the execution context for a connection to the Kernel Fusion Driver (KFD).
20+
*
21+
* This structure encapsulates all state required to manage a KFD session, including:
22+
* - The file descriptor associated with the open KFD device
23+
* - Related resources tied to this file descriptor
24+
*
25+
* Multiple HsaKFDContext instances can coexist simultaneously, each maintaining its own
26+
* independent set of resources. These contexts are fully isolated from one another and
27+
* must not have their resources mixed. For example, memory resources created in
28+
* context A cannot be used in context B directly. If resources need to be shared between
29+
* contexts, they must be explicitly exported and imported using the appropriate APIs.
30+
*/
1631

1732
typedef struct _HsaKFDContext
1833
{

projects/rocr-runtime/libhsakmt/tests/kfdtest/src/KFDQMTest.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,8 @@ bool adjustMask(uint32_t *pAdjMask, uint32_t *pMask, mask_config_t maskConfig) {
10181018
int totalBits = maskConfig.numBits;
10191019
bool nonZero = false;
10201020

1021-
uint32_t tempInactiveMask[maskConfig.numDwords] = { 0 };
1022-
uint32_t tempAdjustMask[maskConfig.numDwords] = { 0 };
1021+
uint32_t *tempInactiveMask = new uint32_t[maskConfig.numDwords]{};
1022+
uint32_t *tempAdjustMask = new uint32_t[maskConfig.numDwords]{};
10231023

10241024
/*
10251025
* KFD encodes all the active WGP at the lowest bits in MQD registers.
@@ -1111,6 +1111,9 @@ bool adjustMask(uint32_t *pAdjMask, uint32_t *pMask, mask_config_t maskConfig) {
11111111
printf("\n");
11121112
#endif //CUMASK_DEBUG
11131113

1114+
delete[] tempInactiveMask;
1115+
delete[] tempAdjustMask;
1116+
11141117
return nonZero;
11151118
}
11161119

0 commit comments

Comments
 (0)