//! ouvre le virtual device passé en param. renvoie ERROR s'il n'y arrive pas et SUCCESS sinon int open_vd(sci_desc_t *vd) { sci_error_t retval; SCIOpen(vd, NO_FLAGS, &retval); if (retval != SCI_ERR_OK) return ERROR; else return SUCCESS; }
sci_error_t SCI_Transporter::initLocalSegment() { DBUG_ENTER("SCI_Transporter::initLocalSegment"); Uint32 segmentSize = m_BufferSize; Uint32 offset = 0; sci_error_t err; if(!m_sciinit) { for(Uint32 i=0; i<m_adapters ; i++) { SCIOpen(&(sciAdapters[i].scidesc), FLAGS, &err); sciAdapters[i].localSciNodeId=getLocalNodeId(i); DBUG_PRINT("info", ("SCInode iD %d adapter %d\n", sciAdapters[i].localSciNodeId, i)); if(err != SCI_ERR_OK) { DBUG_PRINT("error", ("Cannot open an SCI virtual device. Error code 0x%x", err)); DBUG_RETURN(err); } } } m_sciinit=true; SCICreateSegment(sciAdapters[0].scidesc, &(m_SourceSegm[0].localHandle), hostSegmentId(localNodeId, remoteNodeId), segmentSize, 0, 0, 0, &err); if(err != SCI_ERR_OK) { DBUG_PRINT("error", ("Error creating segment, err = 0x%x", err)); DBUG_RETURN(err); } else { DBUG_PRINT("info", ("created segment id : %d", hostSegmentId(localNodeId, remoteNodeId))); } /** Prepare the segment*/ for(Uint32 i=0; i < m_adapters; i++) { SCIPrepareSegment((m_SourceSegm[0].localHandle), i, FLAGS, &err); if(err != SCI_ERR_OK) { DBUG_PRINT("error", ("Local Segment is not accessible by an SCI adapter. Error code 0x%x\n", err)); DBUG_RETURN(err); } } m_SourceSegm[0].mappedMemory = SCIMapLocalSegment((m_SourceSegm[0].localHandle), &(m_SourceSegm[0].lhm[0].map), offset, segmentSize, NULL, FLAGS, &err); if(err != SCI_ERR_OK) { DBUG_PRINT("error", ("Cannot map area of size %d. Error code 0x%x", segmentSize,err)); doDisconnect(); DBUG_RETURN(err); } /** Make the local segment available*/ for(Uint32 i=0; i < m_adapters; i++) { SCISetSegmentAvailable((m_SourceSegm[0].localHandle), i, FLAGS, &err); if(err != SCI_ERR_OK) { DBUG_PRINT("error", ("Local Segment is not available for remote connections. Error code 0x%x\n", err)); DBUG_RETURN(err); } } setupLocalSegment(); DBUG_RETURN(err); } // initLocalSegment()
int main(int argc,char *argv[]) { int counter; printf("\n %s compiled %s : %s\n\n",argv[0],__DATE__,__TIME__); if (argc<3) { Usage(); exit(-1); } /* Get the parameters */ for (counter=1; counter<argc; counter++) { if (!strcmp("-rn",argv[counter])) { // remoteNodeId = strtol(argv[counter+1],(char **) NULL,10); continue; } if (!strcmp("-size",argv[counter])) { segmentSize = strtol(argv[counter+1],(char **) NULL,10); continue; } if (!strcmp("-adapterno",argv[counter])) { localAdapterNo = strtol(argv[counter+1],(char **) NULL,10); continue; } if (!strcmp("-client",argv[counter])) { client = 1; continue; } if (!strcmp("-server",argv[counter])) { server = 1; continue; } if (!strcmp("-help",argv[counter])) { Usage(); exit(0); } } // if (remoteNodeId == 0) { // fprintf(stderr,"Remote node-id is not specified. Use -rn <remote node-id>\n"); // exit(-1); //} if (server == 0 && client == 0) { fprintf(stderr,"You must specify a client node or a server node\n"); exit(-1); } if (server == 1 && client == 1) { fprintf(stderr,"Both server node and client node is selected.\n"); fprintf(stderr,"You must specify either a client or a server node\n"); exit(-1); } /* Initialize the SISCI library */ SCIInitialize(NO_FLAGS, &error); if (error != SCI_ERR_OK) { fprintf(stderr,"SCIInitialize failed - Error code: 0x%x\n",error); exit(error); } /* Open a file descriptor */ SCIOpen(&sdOne,NO_FLAGS,&error); if (error != SCI_ERR_OK) { if (error == SCI_ERR_INCONSISTENT_VERSIONS) { fprintf(stderr,"Version mismatch between SISCI user library and SISCI driver\n"); } fprintf(stderr,"SCIOpen failed - Error code 0x%x\n",error); exit(error); } /* Open a file descriptor */ SCIOpen(&sdTwo,NO_FLAGS,&error); if (error != SCI_ERR_OK) { if (error == SCI_ERR_INCONSISTENT_VERSIONS) { fprintf(stderr,"Version mismatch between SISCI user library and SISCI driver\n"); } fprintf(stderr,"SCIOpen failed - Error code 0x%x\n",error); exit(error); } /* Get local node-id */ error = GetLocalNodeId(localAdapterNo, &localNodeId1); error = GetLocalNodeId(standbyAdapterNo, &localNodeId2); if (error != SCI_ERR_OK) { fprintf(stderr,"Could not find the local adapter %d\n", localAdapterNo); SCIClose(sdOne,NO_FLAGS,&error); SCIClose(sdTwo,NO_FLAGS,&error); exit(-1); } /* Print parameters */ PrintParameters(); if (client) { remoteNodeId1=324; remoteNodeId2=328; ShmemClientNode(); } else { remoteNodeId1=452; remoteNodeId2=456; ShmemServerNode(); } /* Close the file descriptor */ SCIClose(sdOne,NO_FLAGS,&error); SCIClose(sdTwo,NO_FLAGS,&error); if (error != SCI_ERR_OK) { fprintf(stderr,"SCIClose failed - Error code: 0x%x\n",error); } /* Free allocated resources */ SCITerminate(); return SCI_ERR_OK; }