《SNIA-SDC23-Pinto-Computational-Storage-Programming.pdf》由會員分享,可在線閱讀,更多相關《SNIA-SDC23-Pinto-Computational-Storage-Programming.pdf(26頁珍藏版)》請在三個皮匠報告上搜索。
1、1|2023 SNIA.All Rights Reserved.Virtual ConferenceSeptember 28-29,2021Computational Storage ProgrammingOscar P PintoSamsung Semiconductor Inc.Presented by2|2023 SNIA.All Rights Reserved.AgendaOverviewProgramming UsageWalkthrough APIs by ExampleSpecification UpdateSummary3|2023 SNIA.All Rights Reserv
2、ed.Why Computational Storage APIs?Many Compute Interfaces availableMemory based onlyHost 1Host nCSDriverI/OMGMTDevice MemoryComputational Storage Resource(s)Computational StorageEngine(CSE)CSEECSEECSFCSFResource RepositoryCSFCSEECSEECSFFDMAFDMAFDMFabric(PCIe,Ethernet,etc)CSDriverCSDriverCSDriverComp
3、utational Storage Processor(CSP)Host 1Host nCSDriverI/OMGMTStorage ControllerDevice StorageDevice MemoryComputational Storage Resource(s)Computational StorageEngine(CSE)CSEECSEECSFCSFResource RepositoryCSFCSEECSEECSFFDMAFDMAFDMFabric(PCIe,Ethernet,etc)CSDriverCSDriverCSDriverComputational Storage Dr
4、ive(CSD)Host 1Host nCSDriverI/OMGMTStorage ControllerStorage Deviceor CSDDevice MemoryComputational Storage Resource(s)Computational StorageEngine(CSE)CSEECSEECSFCSFResource RepositoryCSFCSEECSEECSFFDMAFDMAFDMFabric(PCIe,Ethernet,etc)CSDriverCSDriverCSDriverArray ControlStorage Deviceor CSDTranspare
5、nt StorageAccessProxiedStorageAccessComputational Storage Array(CSA)SNIA includes all CSx types(CSD,CSP,CSA)Many Compute-Storage optionsTakes near storage compute into accountSNIA CS APIsThis Photo by Unknown Author is licensed under CC BY-NC-ND4|2023 SNIA.All Rights Reserved.SNIA CS APIs1.One set f
6、or all CSx types CSP,CSD,CSA2.Hides Device Details Hardware,Connectivity(local/remote)Vendor specific Implementations3.Abstracts Device Interface Discovery Access Device Memory(mapped/unmapped)Near Storage Access Copy Device Memory Download CSFs Execute CSFs Device ManagementDevice StorageDevice Mem
7、oryCSFCSEECSFStorage ControllerI/OMGMTResourceRepositoryComputational Storage Engine(CSE)Cloud Computing AppsStorage AppsData Analytics AppsDevice driverSNIA CS API LibraryfabricUser-spaceKernel spaceComputational Storage Drive(CSD)SW functionHW functiondecryptdecompresschecksumsearchcomparesortDB-s
8、earcheBPFRTLASICtransformcustomcustomPluginPluginPluginHost SWCSxApplicationsCSP Computational Storage ProcessorCSA Computational Storage ArrayCSF Computational Storage Function5|2023 SNIA.All Rights Reserved.Programming Usage6|2023 SNIA.All Rights Reserved.Programming Modes 2 Programming Modes Priv
9、ileged Mode Operations (Administrator)Configure CS Resources Download CSFs Manage Device Non-privileged Mode Operations(Normal User)Discover CSx,CSFs Allocate Device Memory Execute CSFs Transfer data between Storage&Device Memory(P2P)Copy data between Device Memory&Host Memory7|2023 SNIA.All Rights
10、Reserved.APIs by Example8|2023 SNIA.All Rights Reserved.Example Execute Data Filter1.Discovery Device2.Discover CSF3.Allocate Device Memory(FDM)4.Load Data from Storage5.Run Data Filter CSF on loaded Data6.Copy Results to Host MemoryFDM Function Device Memory Device StorageDevice MemoryStorage Contr
11、ollerComputational Storage Resource(s)ComputationalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputational Storage Drive(CSD)MGMTI/OCSFCSF Device StorageDevice MemoryStorage ControllerComputational Storage Resource(s)ComputationalStorageEngine(CSE)CSEEResource RepositoryFDMAF
12、DMAFDMCSFCSFCSEECSEEComputational Storage Drive(CSD)MGMTI/OCSFCSFSNIA CS API LibraryApplicationHost MemoryInvoke API4123569|2023 SNIA.All Rights Reserved.Prepare for Computational Storage-SetupCSx Computational Storage DeviceCSF Computational Storage Function1Discover CSxDiscover by nameAccess devic
13、e2DiscoverCSFDiscover the function(s)you want to execute3AllocateFDMAllocate Device MemoryReady10|2023 SNIA.All Rights Reserved.Setup:Discover DeviceDiscover CSx Discover CS device Identify the device By device path,path to file/directory By list of all available CS devices Skip this step if device
14、is known1step Access CS device Request access to selected device Device StorageDevice MemoryStorage ControllerComputational Storage Resource(s)ComputationalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputational Storage Drive(CSD)MGMTI/OCSFCSF Device StorageDevice MemoryStora
15、ge ControllerComputational Storage Resource(s)ComputationalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputational Storage Drive(CSD)MGMTI/OCSFCSFSNIA CS API LibraryApplicationHost MemorycsGetCSxFromPath()csOpenCSx()111|2023 SNIA.All Rights Reserved.Setup:Discover FunctionDis
16、cover CSF Discover your CSF By Name or Global Identifier Returns a list of one or more Each CSF instance contains Relative Performance Relative Power Count for this instance FDMs accessible Pick the best one if 1 available2step Device StorageDevice MemoryStorage ControllerComputational Storage Resou
17、rce(s)ComputationalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputational Storage Drive(CSD)MGMTI/OCSFCSF Device StorageDevice MemoryStorage ControllerComputational Storage Resource(s)ComputationalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputationa
18、l Storage Drive(CSD)MGMTI/OCSFCSFSNIA CS API LibraryApplicationHost MemorycsGetCSFId()212|2023 SNIA.All Rights Reserved.Setup:Allocate Device MemoryAllocate FDM Select FDM from Function chosen Select FDM if 1 available Memory should be accessible by compute flow Allocate FDM as necessary Request mem
19、ory with additional details Initialized(clear/fill)Map to Host address spaceIf device permits3step Device StorageDevice MemoryStorage ControllerComputational Storage Resource(s)ComputationalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputational Storage Drive(CSD)MGMTI/OCSFCS
20、F Device StorageDevice MemoryStorage ControllerComputational Storage Resource(s)ComputationalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputational Storage Drive(CSD)MGMTI/OCSFCSFSNIA CS API LibraryApplicationHost MemorycsAllocMem()313|2023 SNIA.All Rights Reserved.Setup:Cod
21、e/Find my CSx near storagestatus=csGetCSxFromPath(“my_file_path,&length,&csxBuffer);if(status!=CS_SUCCESS)ERROR_OUT(No CSx device found!n);/open device,init function and preallocate buffersstatus=csOpenCSx(csxBuffer,devContext,&devHandle);if(status!=CS_SUCCESS)ERROR_OUT(Could not access CSxn);Find C
22、Sx near storageAccess to CSxFind CSF by namePick most performant in list if 1/Get access to the CSF to runstatus=csGetCSFId(devHandle,“filter”,0,&infoLength,&count,&csfInfo);if(status!=CS_SUCCESS)ERROR_OUT(CSX does not contain any decrypt CSFs n);/pick highest performant CSFCSFIdInfo*p=csfInfo;CSFId
23、Info*myCSF=NULL;for(i=0;iRelativePerformance myCSF-RelativePerformance)myCSF=p;printf(“CSFId:%d,RelativePerformance:%dn”,myCSF-CSFId,myCSF-RelativePerformance);Pick most performant FDM in list if 1/Pick most performant FDM for CSF chosenFDMAccess*p=myCSF-FDMList;FDMAccess*myFDM=NULL;for(i=0;i NumFDM
24、s;i+,p+)if(myFDM=NULL)|(myFDM!=NULL)&(p-RelativePerformance myFDM-RelativePerformance)myFDM=p;/allocate FDM for CSF usageCsMemFlags f;f.s-FDMId=myFDM-FDMId;f.s-Flags=0;/may also be CS_FDM_CLEARstatus=csAllocMem(devHandle,CHUNK_SIZE,&f,&afdmHandle1,NULL);if(status!=CS_SUCCESS)ERROR_OUT(AFDM alloc err
25、orn);Allocate required size12314|2023 SNIA.All Rights Reserved.Perform Computational Storage-Run4Load Storage DataLoad Data near Compute5ExecuteCSFRun Compute Operation6Copy ResultsCopy from FDM into Host MemoryDone15|2023 SNIA.All Rights Reserved.Run:Load Storage DataLoad Storage Data Load data fro
26、m storage into FDM Data may be described as LBA ranges File handle&offset Data does not leave the device(P2P)Save on fabric bandwidth More than one Completion options Synchronous Asynchronous Callback or Event4step Device StorageDevice MemoryStorage ControllerComputational Storage Resource(s)Computa
27、tionalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputational Storage Drive(CSD)MGMTI/OCSFCSF Device StorageDevice MemoryStorage ControllerComputational Storage Resource(s)ComputationalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputational Storage Dri
28、ve(CSD)MGMTI/OCSFCSFSNIA CS API LibraryApplicationHost MemorycsQueueStorageRequest()416|2023 SNIA.All Rights Reserved.Run:Execute FunctionExecute CSF Run compute on data loaded in FDM Provide the following CSF to run Parameters to CSF More than one Completion options Synchronous Asynchronous Callbac
29、k or Event5step Device StorageDevice MemoryStorage ControllerComputational Storage Resource(s)ComputationalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputational Storage Drive(CSD)MGMTI/OCSFCSF Device StorageDevice MemoryStorage ControllerComputational Storage Resource(s)Com
30、putationalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputational Storage Drive(CSD)MGMTI/OCSFCSFSNIA CS API LibraryApplicationHost MemorycsQueueComputeRequest()517|2023 SNIA.All Rights Reserved.Run:Copy ResultsCopy FDM contents to Host Copy Results from FDM to Host More than
31、 one Completion options Synchronous Asynchronous Callback or Event6step Device StorageDevice MemoryStorage ControllerComputational Storage Resource(s)ComputationalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputational Storage Drive(CSD)MGMTI/OCSFCSF Device StorageDevice Memo
32、ryStorage ControllerComputational Storage Resource(s)ComputationalStorageEngine(CSE)CSEEResource RepositoryFDMAFDMAFDMCSFCSFCSEECSEEComputational Storage Drive(CSD)MGMTI/OCSFCSFSNIA CS API LibraryApplicationHost MemorycsQueueCopyMemRequest()618|2023 SNIA.All Rights Reserved.Run:Code/Populate storage
33、 request with data from file csStorageRequest storReq=malloc(sizeof(CsStorageRequest);if(!storReq)ERROR_OUT(“not enough memory!n);storReq-Mode=CS_STORAGE_FILE_IO;storReq-DevHandle=devHandle;storReq-u.CsFileIo.Type=CS_STORAGE_LOAD_TYPE;storReq-u.CsFileIo.FileHandle=fd;/file fd to access for datastorR
34、eq-u.CsFileIo.Offset=0;/data offset within filestorReq-u.CsFileIo.Bytes=CHUNK_SIZE;storReq-u.CsFileIo.DevMem.MemHandle=afdmHandle1;storReq-u.CsFileIo.DevMem.ByteOffset=0;status=csQueueStorageRequest(storReq,storReq,NULL,NULL,NULL,&compVal);if(status!=CS_SUCCESS)ERROR_OUT(Could not load storage datan
35、);Callback for completionEvent for completion/Populate compute request on data loaded from file CsComputeRequest compReq=malloc(sizeof(CsComputeRequest)+(sizeof(CsComputeArg)*3);if(!compReq)ERROR_OUT(memory alloc errorn);compReq-CSFId=myCSF-CSFId;/filter function identifiercompReq-NumArgs=3;/functio
36、n accepts 3 parametersCsComputeArg argPtr=&compReq-Args0;csHelperSetComputeArg(&argPtr0,CS_AFDM_TYPE,afdmHandle1,0);/input buffercsHelperSetComputeArg(&argPtr1,CS_32BIT_VALUE_TYPE,CHUNK_SIZE);/length of inputcsHelperSetComputeArg(&argPtr2,CS_AFDM_TYPE,afdmHandle2,0);/output bufferstatus=csQueueCompu
37、teRequest(compReq,compReq,NULL,NULL,NULL,&compVal);if(status!=CS_SUCCESS)ERROR_OUT(“Error in CSF executionn);/Populate copy request for results dataCsCopyMemRequest copyReq=malloc(sizeof(CsCopyMemRequest);if(!copyReq)ERROR_OUT(memory alloc errorn);copyReq-Type=CS_COPY_FROM_DEVICE;copyReq-u.HostVAddr
38、ess=results_buf;copyReq-DevMem.MemHandle=afdmHandle2;copyReq-DevMem.ByteOffset=0;copyReq-Bytes=CHUNK_SIZE;status=csQueueCopyMemRequest(copyReq,copyReq,NULL,NULL,NULL,&compVal);if(status!=CS_SUCCESS)ERROR_OUT(Could not copy data from FDMn);456Completion TypeCallback ParameterEvent ParameterSynchronou
39、sNULLNULLAsynchronous-CallbackNULLAsynchronous-EventNULL19|2023 SNIA.All Rights Reserved.API Summary6 Steps123456Discover Device(CSx)Discover Function(CSF)Allocate Device Memory(FDM)Load Storage Data(P2P)Execute Function(CSF)Copy Results(FDM contents to Host)20|2023 SNIA.All Rights Reserved.Specific
40、ation Update21|2023 SNIA.All Rights Reserved.Specification Update Multiple Updates Include LBA Ranges Advanced Device Memory usage Device Memory Pools and Compute Proximity Initialization Options Cancelling I/O,Abort&Reset Compute Function updates Global Identifiers NVMe Support Configuration&Downlo
41、ad updates SNIA CS API v0.9r1 Specification Public review available In SNIA membership vote towards v1.022|2023 SNIA.All Rights Reserved.Summary23|2023 SNIA.All Rights Reserved.SummaryGrowing Compute requirements are redefining how hardware is usedComputational Storage and APIs help build these solu
42、tionsSNIA CS APIs v0.9r1 Specification Completed Available for Public ReviewSimplified Programming Interface for CSAddresses NVMe CS ArchitectureMinimal steps to adopt24|2023 SNIA.All Rights Reserved.Backup25|2023 SNIA.All Rights Reserved.Complete Code/Find my CSx near storagestatus=csGetCSxFromPath
43、(“my_file_path,&length,&csxBuffer);if(status!=CS_SUCCESS)ERROR_OUT(No CSx device found!n);/open device,init function and prealloc buffersstatus=csOpenCSx(csxBuffer,devContext,&devHandle);if(status!=CS_SUCCESS)ERROR_OUT(Could not access CSxn);/Get access to the CSF to runstatus=csGetCSFId(devHandle,“
44、filter”,0,&infoLength,&count,&csfInfo);if(status!=CS_SUCCESS)ERROR_OUT(CSX does not contain any decrypt CSFs n);/pick highest performant CSFCSFIdInfo*p=csfInfo;CSFIdInfo*myCSF=NULL;for(i=0;iRelativePerformance myCSF-RelativePerformance)myCSF=p;/Pick most performant FDM from CSFIdInfoFDMAccess*p=myCS
45、F-FDMList;FDMAccess*myFDM=NULL;for(i=0;i NumFDMs;i+,p+)if(myFDM=NULL)|(myFDM!=NULL)&(p-RelativePerformance myFDM-RelativePerformance)myFDM=p;/allocate FDM for CSF usageCsMemFlags f;f.s-FDMId=myFDM-FDMId;f.s-Flags=0;/may also be CS_FDM_CLEARstatus=csAllocMem(devHandle,CHUNK_SIZE,&f,&afdmHandle1,NULL)
46、;if(status!=CS_SUCCESS)ERROR_OUT(AFDM alloc errorn);/Populate storage request with data from file csStorageRequest storReq=malloc(sizeof(CsStorageRequest);if(!storReq)ERROR_OUT(“not enough memory!n);storReq-Mode=CS_STORAGE_FILE_IO;storReq-DevHandle=devHandle;storReq-u.CsFileIo.Type=CS_STORAGE_LOAD_T
47、YPE;storReq-u.CsFileIo.FileHandle=fd;/file fd to access for datastorReq-u.CsFileIo.Offset=0;/data offset within filestorReq-u.CsFileIo.Bytes=CHUNK_SIZE;storReq-u.CsFileIo.DevMem.MemHandle=afdmHandle1;storReq-u.CsFileIo.DevMem.ByteOffset=0;status=csQueueStorageRequest(storReq,storReq,NULL,NULL,NULL,&
48、compVal);if(status!=CS_SUCCESS)ERROR_OUT(Could not load storage datan);/Populate compute request on data loaded from file CsComputeRequest compReq=malloc(sizeof(CsComputeRequest)+(sizeof(CsComputeArg)*3);if(!compReq)ERROR_OUT(memory alloc errorn);compReq-CSFId=myCSF-CSFId;/filter function idcompReq-
49、NumArgs=3;/takes 3 argumentsCsComputeArg argPtr=&compReq-Args0;csHelperSetComputeArg(&argPtr0,CS_AFDM_TYPE,afdmHandle1,0);/input buffercsHelperSetComputeArg(&argPtr1,CS_32BIT_VALUE_TYPE,CHUNK_SIZE);/length of inputcsHelperSetComputeArg(&argPtr2,CS_AFDM_TYPE,afdmHandle2,0);/output bufferstatus=csQueu
50、eComputeRequest(compReq,compReq,NULL,NULL,NULL,&compVal);if(status!=CS_SUCCESS)ERROR_OUT(“Error in CSF executionn);/Populate copy request for results dataCsCopyMemRequest copyReq=malloc(sizeof(CsCopyMemRequest);if(!copyReq)ERROR_OUT(memory alloc errorn);copyReq-Type=CS_COPY_FROM_DEVICE;copyReq-u.Hos
51、tVAddress=results_buf;copyReq-DevMem.MemHandle=afdmHandle2;copyReq-DevMem.ByteOffset=0;copyReq-Bytes=CHUNK_SIZE;status=csQueueCopyMemRequest(copyReq,copyReq,NULL,NULL,NULL,NULL);if(status!=CS_SUCCESS)ERROR_OUT(“Could not copy from FDM!n);61234526|2023 SNIA.All Rights Reserved.Please take a moment to rate this session.Your feedback is important to us.