2014-07-29 11:21:10 +03:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2014 Advanced Micro Devices, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including
|
|
|
|
|
* the next paragraph) shall be included in all copies or substantial
|
|
|
|
|
* portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef FMM_H_
|
|
|
|
|
#define FMM_H_
|
|
|
|
|
|
|
|
|
|
#include "hsakmttypes.h"
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
FMM_FIRST_APERTURE_TYPE = 0,
|
|
|
|
|
FMM_GPUVM = FMM_FIRST_APERTURE_TYPE,
|
|
|
|
|
FMM_LDS,
|
|
|
|
|
FMM_SCRATCH,
|
2016-03-09 14:29:37 -05:00
|
|
|
FMM_SVM,
|
2019-04-26 17:42:16 -05:00
|
|
|
FMM_MMIO,
|
2014-07-29 11:21:10 +03:00
|
|
|
FMM_LAST_APERTURE_TYPE
|
|
|
|
|
} aperture_type_e;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
aperture_type_e app_type;
|
|
|
|
|
uint64_t size;
|
2017-04-20 08:25:00 -04:00
|
|
|
void *start_address;
|
2014-07-29 11:21:10 +03:00
|
|
|
} aperture_properties_t;
|
|
|
|
|
|
2016-01-14 17:07:28 -05:00
|
|
|
HSAKMT_STATUS fmm_init_process_apertures(unsigned int NumNodes);
|
2016-01-13 17:27:31 -05:00
|
|
|
void fmm_destroy_process_apertures(void);
|
|
|
|
|
|
2017-04-20 08:25:00 -04:00
|
|
|
/* Memory interface */
|
2018-10-16 14:26:42 -04:00
|
|
|
void *fmm_allocate_scratch(uint32_t gpu_id, void *address, uint64_t MemorySizeInBytes);
|
2021-07-16 16:19:02 -04:00
|
|
|
void *fmm_allocate_device(uint32_t gpu_id, uint32_t node_id, void *address,
|
|
|
|
|
uint64_t MemorySizeInBytes, HsaMemFlags flags);
|
2017-04-20 08:25:00 -04:00
|
|
|
void *fmm_allocate_doorbell(uint32_t gpu_id, uint64_t MemorySizeInBytes, uint64_t doorbell_offset);
|
2018-10-16 14:26:42 -04:00
|
|
|
void *fmm_allocate_host(uint32_t node_id, void *address, uint64_t MemorySizeInBytes,
|
2016-09-01 23:25:42 -04:00
|
|
|
HsaMemFlags flags);
|
2014-07-29 11:21:10 +03:00
|
|
|
void fmm_print(uint32_t node);
|
2018-06-20 13:30:06 +08:00
|
|
|
HSAKMT_STATUS fmm_release(void *address);
|
2015-02-22 13:06:50 +02:00
|
|
|
int fmm_map_to_gpu(void *address, uint64_t size, uint64_t *gpuvm_address);
|
|
|
|
|
int fmm_unmap_from_gpu(void *address);
|
2015-08-23 17:42:27 +03:00
|
|
|
bool fmm_get_handle(void *address, uint64_t *handle);
|
2016-09-01 23:25:42 -04:00
|
|
|
HSAKMT_STATUS fmm_get_mem_info(const void *address, HsaPointerInfo *info);
|
|
|
|
|
HSAKMT_STATUS fmm_set_mem_user_data(const void *mem, void *usr_data);
|
2014-07-29 11:21:10 +03:00
|
|
|
|
|
|
|
|
/* Topology interface*/
|
|
|
|
|
HSAKMT_STATUS fmm_node_added(HSAuint32 gpu_id);
|
|
|
|
|
HSAKMT_STATUS fmm_node_removed(HSAuint32 gpu_id);
|
2015-10-22 21:32:41 -04:00
|
|
|
HSAKMT_STATUS fmm_get_aperture_base_and_limit(aperture_type_e aperture_type, HSAuint32 gpu_id,
|
|
|
|
|
HSAuint64 *aperture_base, HSAuint64 *aperture_limit);
|
2015-12-23 17:23:25 +02:00
|
|
|
|
2015-11-06 18:28:30 -05:00
|
|
|
HSAKMT_STATUS fmm_register_memory(void *address, uint64_t size_in_bytes,
|
2017-04-20 08:25:00 -04:00
|
|
|
uint32_t *gpu_id_array,
|
2019-03-26 02:22:29 -05:00
|
|
|
uint32_t gpu_id_array_size,
|
|
|
|
|
bool coarse_grain);
|
2016-03-05 01:12:40 -05:00
|
|
|
HSAKMT_STATUS fmm_register_graphics_handle(HSAuint64 GraphicsResourceHandle,
|
|
|
|
|
HsaGraphicsResourceInfo *GraphicsResourceInfo,
|
|
|
|
|
uint32_t *gpu_id_array,
|
|
|
|
|
uint32_t gpu_id_array_size);
|
2016-01-07 16:28:20 -05:00
|
|
|
HSAKMT_STATUS fmm_deregister_memory(void *address);
|
2017-04-20 08:25:00 -04:00
|
|
|
HSAKMT_STATUS fmm_share_memory(void *MemoryAddress,
|
2016-11-22 14:35:35 -05:00
|
|
|
HSAuint64 SizeInBytes,
|
|
|
|
|
HsaSharedMemoryHandle *SharedMemoryHandle);
|
|
|
|
|
HSAKMT_STATUS fmm_register_shared_memory(const HsaSharedMemoryHandle *SharedMemoryHandle,
|
|
|
|
|
HSAuint64 *SizeInBytes,
|
|
|
|
|
void **MemoryAddress,
|
|
|
|
|
uint32_t *gpu_id_array,
|
|
|
|
|
uint32_t gpu_id_array_size);
|
2016-02-24 17:30:48 +02:00
|
|
|
HSAKMT_STATUS fmm_map_to_gpu_nodes(void *address, uint64_t size,
|
2017-08-15 17:13:55 -04:00
|
|
|
uint32_t *nodes_to_map, uint64_t num_of_nodes, uint64_t *gpuvm_address);
|
2018-08-14 13:39:22 -04:00
|
|
|
|
|
|
|
|
int open_drm_render_device(int minor);
|
2014-07-29 11:21:10 +03:00
|
|
|
#endif /* FMM_H_ */
|