void cmpi_client_code() { NOTE_F; gossip_set_debug_mask(1, MASK_MPIRPC|MASK_DHT); // wait_for_notification(); // notify_next(); sleep(2); cmpi_debug_tables(); sleep(mpi_rank); if (mpi_rank == mpi_size-1) cmpi_shutdown(); }
int main( int argc, char **argv) { int ret = -1; int outcount = 0, count; struct BMI_unexpected_info request_info; flow_descriptor *flow_d = NULL; double time1, time2; int i; PINT_Request *req; char path_name[PATH_SIZE]; TROVE_op_id op_id; TROVE_coll_id coll_id; TROVE_handle file_handle, parent_handle; TROVE_ds_state state; char *file_name; TROVE_keyval_s key, val; bmi_context_id context; TROVE_context_id trove_context; PVFS_handle_extent cur_extent; PVFS_handle_extent_array extent_array; /*************************************************************/ /* initialization stuff */ /* set debugging level */ gossip_enable_stderr(); gossip_set_debug_mask(0, GOSSIP_FLOW_PROTO_DEBUG | GOSSIP_BMI_DEBUG_TCP ); /* start up BMI */ ret = BMI_initialize("bmi_tcp", "tcp://NULL:3335", BMI_INIT_SERVER); if (ret < 0) { fprintf(stderr, "BMI init failure.\n"); return (-1); } ret = BMI_open_context(&context); if (ret < 0) { fprintf(stderr, "BMI_open_context() failure.\n"); return (-1); } ret = trove_initialize( TROVE_METHOD_DBPF, NULL, storage_space, 0); if (ret < 0) { fprintf(stderr, "initialize failed: run trove-mkfs first.\n"); return -1; } /* initialize the flow interface. protocol specific */ ret = PINT_flow_initialize("flowproto_bmi_cache", 0); if (ret < 0) { fprintf(stderr, "flow init failure.\n"); return (-1); } /* try to look up collection used to store file system */ ret = trove_collection_lookup( TROVE_METHOD_DBPF, file_system, &coll_id, NULL, &op_id); if (ret < 0) { fprintf(stderr, "collection lookup failed.\n"); return -1; } ret = trove_open_context(coll_id, &trove_context); if (ret < 0) { fprintf(stderr, "TROVE_open_context() failure.\n"); return (-1); } /* find the parent directory name */ strcpy(path_name, path_to_file); for (i = strlen(path_name); i >= 0; i--) { if (path_name[i] != '/') path_name[i] = '\0'; else break; } file_name = path_to_file + strlen(path_name); printf("path is %s\n", path_name); printf("file is %s\n", file_name); /* find the parent directory handle */ ret = path_lookup(coll_id, trove_context, path_name, &parent_handle); if (ret < 0) { return -1; } file_handle = 0; cur_extent.first = cur_extent.last = requested_file_handle; extent_array.extent_count = 1; extent_array.extent_array = &cur_extent; ret = trove_dspace_create(coll_id, &extent_array, &file_handle, TROVE_TEST_FILE, NULL, TROVE_FORCE_REQUESTED_HANDLE, NULL, trove_context, &op_id, NULL); while (ret == 0) ret = trove_dspace_test(coll_id, op_id, trove_context, &count, NULL, NULL, &state, TROVE_DEFAULT_TEST_TIMEOUT); if (ret < 0) { fprintf(stderr, "dspace create failed.\n"); return -1; } /* TODO: set attributes of file? */ /* add new file name/handle pair to parent directory */ key.buffer = file_name; key.buffer_sz = strlen(file_name) + 1; val.buffer = &file_handle; val.buffer_sz = sizeof(file_handle); ret = trove_keyval_write(coll_id, parent_handle, &key, &val, 0, NULL, NULL, trove_context, &op_id, NULL); while (ret == 0) ret = trove_dspace_test(coll_id, op_id, trove_context, &count, NULL, NULL, &state, TROVE_DEFAULT_TEST_TIMEOUT); if (ret < 0) { fprintf(stderr, "keyval write failed.\n"); return -1; } /* wait for an initial communication via BMI */ /* we don't give a crap about that message except that it tells us * where to find the client */ do { ret = BMI_testunexpected(1, &outcount, &request_info, 10); } while (ret == 0 && outcount == 0); if (ret < 0 || request_info.error_code != 0) { fprintf(stderr, "waitunexpected failure.\n"); return (-1); } BMI_unexpected_free(request_info.addr, request_info.buffer); /******************************************************/ /* setup request/dist stuff */ /* request description */ /* just want one contiguous region */ ret = PVFS_Request_contiguous(TEST_SIZE, PVFS_BYTE, &req); if (ret < 0) { fprintf(stderr, "PVFS_Request_contiguous() failure.\n"); return (-1); } /******************************************************/ /* setup communicaton stuff */ /* create a flow descriptor */ flow_d = PINT_flow_alloc(); if (!flow_d) { fprintf(stderr, "flow_alloc failed.\n"); return (-1); } /* file data */ flow_d->file_data.fsize = TEST_SIZE; flow_d->file_data.server_nr = 0; flow_d->file_data.server_ct = 1; flow_d->file_data.extend_flag = 1; flow_d->file_data.dist = PINT_dist_create("basic_dist"); if (!flow_d->file_data.dist) { fprintf(stderr, "Error: failed to create dist.\n"); return (-1); } ret = PINT_dist_lookup(flow_d->file_data.dist); if (ret != 0) { fprintf(stderr, "Error: failed to lookup dist.\n"); return (-1); } flow_d->file_req = req; flow_d->tag = 0; flow_d->user_ptr = NULL; flow_d->aggregate_size = TEST_SIZE; /* fill in flow details */ flow_d->src.endpoint_id = BMI_ENDPOINT; flow_d->src.u.bmi.address = request_info.addr; flow_d->dest.endpoint_id = TROVE_ENDPOINT; flow_d->dest.u.trove.handle = file_handle; flow_d->dest.u.trove.coll_id = coll_id; /*************************************************** * test bmi to file (analogous to a client side write) */ time1 = Wtime(); ret = block_on_flow(flow_d); if (ret < 0) { return (-1); } time2 = Wtime(); #if 0 printf("Server bw (recv): %f MB/sec\n", ((TEST_SIZE) / ((time2 - time1) * 1000000.0))); #endif /*******************************************************/ /* final cleanup and output */ PINT_flow_free(flow_d); /* shut down flow interface */ ret = PINT_flow_finalize(); if (ret < 0) { fprintf(stderr, "flow finalize failure.\n"); return (-1); } /* shut down BMI */ BMI_close_context(context); BMI_finalize(); trove_close_context(coll_id, trove_context); trove_finalize(TROVE_METHOD_DBPF); gossip_disable(); return (0); }
int main( int argc, char **argv) { int ret; struct PVFS_server_req req_array[4]; req_sched_id id_array[4]; req_sched_id id_arrayB[4]; struct PVFS_server_req io_req_array[4]; req_sched_id io_id_array[4]; req_sched_id io_id_arrayB[4]; int count = 0; int status = 0; req_sched_id timer_id_array[2]; /* setup some requests to test */ req_array[0].op = PVFS_SERV_GETATTR; req_array[0].u.getattr.handle = 5; req_array[1].op = PVFS_SERV_SETATTR; req_array[1].u.setattr.handle = 5; req_array[2].op = PVFS_SERV_GETATTR; req_array[2].u.getattr.handle = 6; req_array[3].op = PVFS_SERV_SETATTR; req_array[3].u.setattr.handle = 5; io_req_array[0].op = PVFS_SERV_IO; io_req_array[0].u.io.handle = 5; io_req_array[1].op = PVFS_SERV_IO; io_req_array[1].u.io.handle = 5; io_req_array[2].op = PVFS_SERV_IO; io_req_array[2].u.io.handle = 5; io_req_array[3].op = PVFS_SERV_IO; io_req_array[3].u.io.handle = 5; /* turn on gossip for the scheduler */ gossip_enable_stderr(); gossip_set_debug_mask(1, GOSSIP_REQ_SCHED_DEBUG); /* initialize scheduler */ ret = PINT_req_sched_initialize(); if (ret < 0) { fprintf(stderr, "Error: initialize failure.\n"); return (-1); } /* try to schedule first request- it should proceed */ ret = PINT_req_sched_post(&(req_array[0]), 0, NULL, &(id_array[0])); if (ret != 1) { fprintf(stderr, "Error: 1st post should immediately complete.\n"); return (-1); } /* try to schedule second request- it should queue up */ ret = PINT_req_sched_post(&(req_array[1]), 0, NULL, &(id_array[1])); if (ret != 0) { fprintf(stderr, "Error: 2nd post should queue.\n"); return (-1); } /* schedule two I/O requests */ ret = PINT_req_sched_post(&(io_req_array[1]), 0, NULL, &(io_id_array[1])); if (ret != 0) { fprintf(stderr, "Error: 1st I/O req should queue.\n"); return (-1); } ret = PINT_req_sched_post(&(io_req_array[0]), 0, NULL, &(io_id_array[0])); if (ret != 0) { fprintf(stderr, "Error: 1st I/O req should queue.\n"); return (-1); } /* try to schedule third request- it should proceed */ ret = PINT_req_sched_post(&(req_array[2]), 0, NULL, &(id_array[2])); if (ret != 1) { fprintf(stderr, "Error: 3rd post should immediately complete.\n"); return (-1); } /* try to schedule fourth request- it should queue up */ ret = PINT_req_sched_post(&(req_array[3]), 0, NULL, &(id_array[3])); if (ret != 0) { fprintf(stderr, "Error: 4th post should queue.\n"); return (-1); } /*********************************************************/ /* test the second one and make sure it doesn't finish */ ret = PINT_req_sched_test(id_array[1], &count, NULL, &status); if (ret != 0 || count != 0) { fprintf(stderr, "Error: test of 2nd request failed.\n"); return (-1); } /* unpost the 2nd request */ ret = PINT_req_sched_unpost(id_array[1], NULL); if (ret != 0) { fprintf(stderr, "Error: upost failure.\n"); return (-1); } /* complete the first request */ ret = PINT_req_sched_release(id_array[0], NULL, &(id_arrayB[0])); if (ret != 1) { fprintf(stderr, "Error: release didn't immediately complete.\n"); return (-1); } /* 4th request should still block on i/o requests */ ret = PINT_req_sched_test(id_array[3], &count, NULL, &status); if (ret != 0 || count != 0) { fprintf(stderr, "Error: test of 4th request failed.\n"); return (-1); } /* see if the first two i/o requests are ready */ /* test out of order, to make sure that works */ ret = PINT_req_sched_test(io_id_array[1], &count, NULL, &status); if (ret != 1 || count != 1 || status != 0) { fprintf(stderr, "Error: test of 2nd io request failed.\n"); return (-1); } ret = PINT_req_sched_test(io_id_array[0], &count, NULL, &status); if (ret != 1 || count != 1 || status != 0) { fprintf(stderr, "Error: test of 2nd io request failed.\n"); return (-1); } /* 4th request should still block on i/o requests */ ret = PINT_req_sched_test(id_array[3], &count, NULL, &status); if (ret != 0 || count != 0) { fprintf(stderr, "Error: test of 4th request failed.\n"); return (-1); } /* release the first two io requests */ ret = PINT_req_sched_release(io_id_array[1], NULL, &(io_id_arrayB[1])); if (ret != 1) { fprintf(stderr, "Error: release didn't immediately complete.\n"); return (-1); } ret = PINT_req_sched_release(io_id_array[0], NULL, &(io_id_arrayB[0])); if (ret != 1) { fprintf(stderr, "Error: release didn't immediately complete.\n"); return (-1); } /* now the 4th request should be ready to go */ ret = PINT_req_sched_test(id_array[3], &count, NULL, &status); if (ret != 1 || count != 1 || status != 0) { fprintf(stderr, "Error: test of 4th request failed.\n"); return (-1); } /* complete the 3rd and 4th requests */ ret = PINT_req_sched_release(id_array[2], NULL, &(id_arrayB[2])); if (ret != 1) { fprintf(stderr, "Error: release didn't immediately complete.\n"); return (-1); } ret = PINT_req_sched_release(id_array[3], NULL, &(id_arrayB[3])); if (ret != 1) { fprintf(stderr, "Error: release didn't immediately complete.\n"); return (-1); } /* schedule two more I/O requests, should both immediately complete */ ret = PINT_req_sched_post(&(io_req_array[2]), 0, NULL, &(io_id_array[2])); if (ret != 1) { fprintf(stderr, "Error: 3rd I/O req should complete.\n"); return (-1); } ret = PINT_req_sched_post(&(io_req_array[3]), 0, NULL, &(io_id_array[3])); if (ret != 1) { fprintf(stderr, "Error: 4th I/O req should complete.\n"); return (-1); } /* release last two i/o requests */ ret = PINT_req_sched_release(io_id_array[3], NULL, &(io_id_arrayB[3])); if (ret != 1) { fprintf(stderr, "Error: release didn't immediately complete.\n"); return (-1); } ret = PINT_req_sched_release(io_id_array[2], NULL, &(io_id_arrayB[2])); if (ret != 1) { fprintf(stderr, "Error: release didn't immediately complete.\n"); return (-1); } /* try a simple timer case */ ret = PINT_req_sched_post_timer(1500, NULL, &(timer_id_array[0])); if (ret != 0) { fprintf(stderr, "Error: post timer weirdness.\n"); return (-1); } ret = PINT_req_sched_post_timer(1000, NULL, &(timer_id_array[1])); if (ret != 0) { fprintf(stderr, "Error: post timer weirdness.\n"); return (-1); } do { count = 2; ret = PINT_req_sched_testworld(&count, timer_id_array, NULL, &status); } while (ret == 0 && count == 0); assert(ret == 1 && count == 1 && status == 0); if (ret < 0 || status != 0) { fprintf(stderr, "Error: test failure.\n"); } printf("Done 1.\n"); do { count = 2; ret = PINT_req_sched_testworld(&count, timer_id_array, NULL, &status); } while (ret == 0 && count == 0); assert(ret == 1 && count == 1 && status == 0); if (ret < 0 || status != 0) { fprintf(stderr, "Error: test failure.\n"); } printf("Done 2.\n"); /* shut down scheduler */ ret = PINT_req_sched_finalize(); if (ret < 0) { fprintf(stderr, "Error: finalize failure.\n"); return (-1); } return (0); }
main(int argc, char **argv) { int i; PINT_Request req1; PINT_Request req2; PINT_Request req3; // PVFS_Process_request arguments PINT_Request_state *reqs; PVFS_Dist_parm dparm; PINT_Request_file_data rfdata; int32_t segmax; PVFS_offset *offset_array; PVFS_size *size_array; PVFS_offset offset; PVFS_size bytemax; PVFS_boolean eof_flag; // Turn on debugging gossip_enable_stderr(); gossip_set_debug_mask(1,REQUEST_DEBUG); req2.offset = 0; // This is a byte type req2.num_ereqs = 1; req2.stride = 0; req2.num_blocks = 1; req2.ub = 1; req2.lb = 0; req2.aggregate_size = 1; req2.depth = 0; req2.num_contig_chunks = 1; req2.ereq = NULL; req2.sreq = NULL; req3.offset = 0; req3.num_ereqs = 8; req3.stride = 20; req3.num_blocks = 20; req3.ub = 400; req3.lb = 0; req3.aggregate_size = 160; req3.depth = 1; req3.num_contig_chunks = 20; req3.ereq = &req2; req3.sreq = NULL; req1.offset = 0; req1.num_ereqs = 4; req1.stride = 2000; req1.num_blocks = 10; req1.ub = 19600; req1.lb = 0; req1.aggregate_size = 6400; req1.depth = 2; req1.num_contig_chunks = 800; req1.ereq = &req3; req1.sreq = NULL; reqs = PINT_new_request_state(&req1); rfdata.server_nr = 0; rfdata.server_ct = 2; rfdata.fsize = 10000000; rfdata.dist = PINT_lookup_distribution("simple stripe"); dparm.strip_size = 1024; rfdata.dparm = &dparm; rfdata.extend_flag = 0; offset_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t)); size_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t)); eof_flag = 0; offset = 0; do { segmax = SEGMAX; bytemax = BYTEMAX; PINT_process_request(reqs, &rfdata, &segmax, offset_array, size_array, &offset, &bytemax, &eof_flag, PINT_SERVER); printf("processed %lld bytes in %d segments\n", bytemax, segmax); for (i = 0; i < segmax; i++) { printf("segment %d: offset=%lld size=%lld\n", i, offset_array[i], size_array[i]); } } while (offset != -1); }
int main( int argc, char **argv) { struct options *user_opts = NULL; struct server_request *my_req = NULL; struct server_ack *my_ack = NULL; int ret = -1; PVFS_BMI_addr_t client_addr; void *recv_buffer1 = NULL; void *recv_buffer2 = NULL; bmi_op_id_t server_ops[2]; bmi_error_code_t error_code; int outcount = 0; struct BMI_unexpected_info request_info; bmi_size_t actual_size; bmi_size_t size_list[2]; void *buffer_list[2]; int last = 0; int i = 0; bmi_context_id context; char method[24], *cp; int len; /* grab any command line options */ user_opts = parse_args(argc, argv); if (!user_opts) { return (-1); } /* set debugging stuff */ gossip_enable_stderr(); gossip_set_debug_mask(0, GOSSIP_BMI_DEBUG_ALL); /* convert address to bmi method type by prefixing bmi_ */ cp = strchr(user_opts->hostid, ':'); if (!cp) return 1; len = cp - user_opts->hostid; strcpy(method, "bmi_"); strncpy(method + 4, user_opts->hostid, len); method[4+len] = '\0'; /* initialize local interface (default options) */ ret = BMI_initialize(method, user_opts->hostid, BMI_INIT_SERVER); if (ret < 0) { errno = -ret; perror("BMI_initialize"); return (-1); } ret = BMI_open_context(&context); if (ret < 0) { errno = -ret; perror("BMI_open_context()"); return (-1); } /* wait for an initial request */ do { ret = BMI_testunexpected(1, &outcount, &request_info, 10); } while (ret == 0 && outcount == 0); if (ret < 0) { fprintf(stderr, "Request recv failure (bad state).\n"); errno = -ret; perror("BMI_testunexpected"); return (-1); } if (request_info.error_code != 0) { fprintf(stderr, "Request recv failure (bad state).\n"); return (-1); } printf("Received a new request.\n"); if (request_info.size != sizeof(struct server_request)) { fprintf(stderr, "Bad Request!\n"); exit(-1); } my_req = (struct server_request *) request_info.buffer; client_addr = request_info.addr; /* create an ack */ my_ack = (struct server_ack *) BMI_memalloc(client_addr, sizeof(struct server_ack), BMI_SEND); if (!my_ack) { fprintf(stderr, "BMI_memalloc failed.\n"); return (-1); } memset(my_ack, 0, sizeof(struct server_ack)); /* create 2 buffers to recv into */ recv_buffer1 = BMI_memalloc(client_addr, (my_req->size / 2), BMI_RECV); recv_buffer2 = BMI_memalloc(client_addr, (my_req->size - (my_req->size / 2)), BMI_RECV); if (!recv_buffer1 || !recv_buffer2) { fprintf(stderr, "BMI_memalloc failed.\n"); return (-1); } buffer_list[0] = recv_buffer1; buffer_list[1] = recv_buffer2; size_list[0] = my_req->size / 2; size_list[1] = my_req->size - (my_req->size / 2); /* post the ack */ ret = BMI_post_send(&(server_ops[1]), client_addr, my_ack, sizeof(struct server_ack), BMI_PRE_ALLOC, 0, NULL, context, NULL); if (ret < 0) { fprintf(stderr, "BMI_post_send_failure.\n"); return (-1); } if (ret == 0) { /* turning this into a blocking call for testing :) */ /* check for completion of ack send */ do { ret = BMI_test(server_ops[1], &outcount, &error_code, &actual_size, NULL, 10, context); } while (ret == 0 && outcount == 0); if (ret < 0 || error_code != 0) { fprintf(stderr, "ack send failed.\n"); return (-1); } } /* post the recv */ ret = BMI_post_recv_list(&(server_ops[0]), client_addr, buffer_list, size_list, 2, my_req->size, &actual_size, BMI_PRE_ALLOC, 0, NULL, context, NULL); if (ret < 0) { fprintf(stderr, "BMI_post_recv_failure.\n"); return (-1); } if (ret == 0) { /* turning this into a blocking call for testing :) */ /* check for completion of data payload recv */ do { ret = BMI_test(server_ops[0], &outcount, &error_code, &actual_size, NULL, 10, context); } while (ret == 0 && outcount == 0); if (ret < 0 || error_code != 0) { fprintf(stderr, "data recv failed.\n"); return (-1); } } if (actual_size != my_req->size) { printf("Short recv.\n"); printf("diff: %d\n", (int) (my_req->size - actual_size)); } /* check validity of received message */ for (i = 0; i < ((my_req->size / 2) / sizeof(int)); i++) { if (((int *) recv_buffer1)[i] != i) { fprintf(stderr, "Validation failure, offset %d.\n", i); } } last = i; for (i = last; i < (last + ((my_req->size - (my_req->size / 2)) / sizeof(int))); i++) { if (((int *) recv_buffer2)[i - last] != i) { fprintf(stderr, "Validation failure, offset %d.\n", i); } } /* free up the message buffers */ BMI_memfree(client_addr, recv_buffer1, (my_req->size / 2), BMI_RECV); BMI_memfree(client_addr, recv_buffer2, (my_req->size - (my_req->size / 2)), BMI_RECV); BMI_memfree(client_addr, my_ack, sizeof(struct server_ack), BMI_SEND); BMI_unexpected_free(client_addr, my_req); /* shutdown the local interface */ BMI_close_context(context); ret = BMI_finalize(); if (ret < 0) { errno = -ret; perror("BMI_finalize"); return (-1); } /* turn off debugging stuff */ gossip_disable(); free(user_opts->hostid); free(user_opts); return (0); }
int main(int argc, char **argv) { struct options *opts = NULL; int ret = -1; bmi_context_id context; /* grab any command line options */ opts = parse_args(argc, argv); if (!opts) { print_usage(); return (-1); } /* set debugging stuff */ gossip_enable_stderr(); gossip_set_debug_mask(0, GOSSIP_BMI_DEBUG_ALL); #ifdef WIN32 /* get performance counter frequency */ QueryPerformanceFrequency(&freq); #endif /* initialize local interface (default options) */ if (opts->which == SERVER) ret = BMI_initialize(opts->method, opts->hostid, BMI_INIT_SERVER); else ret = BMI_initialize(NULL, NULL, 0); if (ret < 0) { errno = -ret; perror("BMI_initialize"); return (-1); } ret = BMI_open_context(&context); if (ret < 0) { errno = -ret; perror("BMI_open_context()"); return (-1); } if (opts->which == SERVER) { ret = do_server(opts, &context); } else { ret = do_client(opts, &context); } /* shutdown the local interface */ BMI_close_context(context); ret = BMI_finalize(); if (ret < 0) { errno = -ret; perror("BMI_finalize"); return (-1); } /* turn off debugging stuff */ gossip_disable(); return (0); }
int main( int argc, char **argv) { int ret = -1; int outcount = 0; void *mybuffer; PVFS_BMI_addr_t server_addr; bmi_op_id_t op; bmi_error_code_t error_code; flow_descriptor *flow_d = NULL; int i = 0; bmi_size_t actual_size; double time1, time2; PINT_Request *req; bmi_context_id context; /*************************************************************/ /* initialization stuff */ /* set debugging level */ gossip_enable_stderr(); gossip_set_debug_mask( 0, (GOSSIP_FLOW_PROTO_DEBUG | GOSSIP_BMI_DEBUG_TCP)); /* Dist init */ PINT_dist_initialize(NULL); /* start up BMI */ ret = BMI_initialize("bmi_tcp", NULL, 0); if (ret < 0) { fprintf(stderr, "BMI init failure.\n"); return (-1); } ret = BMI_open_context(&context); if (ret < 0) { fprintf(stderr, "BMI_open_context() failure.\n"); return (-1); } /* initialize the flow interface */ ret = PINT_flow_initialize("flowproto_multiqueue", 0); if (ret < 0) { fprintf(stderr, "flow init failure.\n"); return (-1); } /* send some random crap to the other side to start up communication */ ret = BMI_addr_lookup(&server_addr, "tcp://localhost:3335"); if (ret < 0) { fprintf(stderr, "BMI lookup failure.\n"); return (-1); } ret = BMI_post_sendunexpected(&op, server_addr, &mybuffer, 1, BMI_EXT_ALLOC, 0, NULL, context, NULL); if (ret < 0) { fprintf(stderr, "BMI_post_sendunexpected failure.\n"); return (-1); } if (ret == 0) { /* turning this into a blocking call for testing :) */ /* check for completion of request */ do { ret = BMI_test(op, &outcount, &error_code, &actual_size, NULL, 10, context); } while (ret == 0 && outcount == 0); if (ret < 0 || error_code != 0) { fprintf(stderr, "Request send failed.\n"); if (ret < 0) { errno = -ret; perror("BMI_test"); } return (-1); } } /******************************************************/ /* setup request/dist stuff */ /* request description */ /* just want one contiguous region */ ret = PVFS_Request_contiguous(TEST_SIZE, PVFS_BYTE, &req); if (ret < 0) { fprintf(stderr, "PVFS_Request_contiguous() failure.\n"); return (-1); } /******************************************************/ /* setup communicaton stuff */ /* memory buffer to xfer */ mybuffer = (void *) malloc(TEST_SIZE); if (!mybuffer) { fprintf(stderr, "mem.\n"); return (-1); } /* mark it so that we can check correctness */ for (i = 0; i < (TEST_SIZE / (sizeof(int))); i++) { ((int *) mybuffer)[i] = i; } /* create a flow descriptor */ flow_d = PINT_flow_alloc(); if (!flow_d) { fprintf(stderr, "mem.\n"); return (-1); } /* file data */ flow_d->file_data.fsize = TEST_SIZE; flow_d->file_data.server_nr = 0; flow_d->file_data.server_ct = 1; flow_d->file_data.extend_flag = 0; flow_d->file_data.dist = PINT_dist_create("basic_dist"); if (!flow_d->file_data.dist) { fprintf(stderr, "Error: failed to create dist.\n"); return (-1); } ret = PINT_dist_lookup(flow_d->file_data.dist); if (ret != 0) { fprintf(stderr, "Error: failed to lookup dist.\n"); return (-1); } flow_d->file_req = req; flow_d->tag = 0; flow_d->user_ptr = NULL; flow_d->aggregate_size = TEST_SIZE; /* fill in flow details */ flow_d->src.endpoint_id = MEM_ENDPOINT; flow_d->src.u.mem.buffer = mybuffer; flow_d->dest.endpoint_id = BMI_ENDPOINT; flow_d->dest.u.bmi.address = server_addr; /*************************************************** * test memory to bmi (analogous to client side write) */ time1 = Wtime(); ret = block_on_flow(flow_d); if (ret < 0) { return (-1); } time2 = Wtime(); /*******************************************************/ /* final cleanup and output */ #if 0 printf("Client bw (send): %f MB/sec\n", ((TEST_SIZE) / ((time2 - time1) * 1000000.0))); #endif PINT_flow_free(flow_d); /* shut down flow interface */ ret = PINT_flow_finalize(); if (ret < 0) { fprintf(stderr, "flow finalize failure.\n"); return (-1); } /* shut down BMI */ BMI_close_context(context); BMI_finalize(); free(mybuffer); gossip_disable(); return (0); }
int main(int argc, char **argv) { int ret = -1; struct request_foo* req = NULL; struct ack_foo* ack = NULL; PVFS_BMI_addr_t server_addr; job_status_s status1; job_id_t tmp_id; job_context_id context; /* set debugging level */ gossip_enable_stderr(); gossip_set_debug_mask(0, 0); /* start the BMI interface */ ret = BMI_initialize("bmi_tcp", NULL, 0); if(ret < 0) { fprintf(stderr, "BMI_initialize failure.\n"); return(-1); } ret = trove_initialize( TROVE_METHOD_DBPF, NULL, "/tmp/pvfs2-test-space", 0); if(ret < 0) { fprintf(stderr, "trove_initialize failure.\n"); return(-1); } /* start the job interface */ ret = job_initialize(0); if(ret < 0) { fprintf(stderr, "job_initialize failure.\n"); return(-1); } ret = job_open_context(&context); if(ret < 0) { fprintf(stderr, "job_open_context() failure.\n"); return(-1); } /* lookup the server to get a BMI style address for it */ ret = BMI_addr_lookup(&server_addr, "tcp://localhost:3414"); if(ret < 0) { fprintf(stderr, "BMI_addr_lookup failure.\n"); return(-1); } /* allocate some buffers for the req and ack */ req = BMI_memalloc(server_addr, sizeof(struct request_foo), BMI_SEND); ack = BMI_memalloc(server_addr, sizeof(struct ack_foo), BMI_RECV); if(!ack || ! req) { fprintf(stderr, "BMI_memalloc failure.\n"); return(-1); } /* send a message */ ret = job_bmi_send(server_addr, req, sizeof(struct request_foo), 0, BMI_PRE_ALLOC, 1, NULL, 0, &status1, &tmp_id, context, JOB_TIMEOUT_INF, NULL); if(ret < 0) { fprintf(stderr, "job_bmi_send() failure.\n"); return(-1); } if(ret == 0) { int count = 0; ret = job_test(tmp_id, &count, NULL, &status1, -1, context); if(ret < 0) { fprintf(stderr, "job_test() failure.\n"); return(-1); } } /* check status */ if(status1.error_code != 0) { fprintf(stderr, "job failure.\n"); return(-1); } /* receive a message */ ret = job_bmi_recv(server_addr, ack, sizeof(struct ack_foo), 0, BMI_PRE_ALLOC, NULL, 0, &status1, &tmp_id, context, JOB_TIMEOUT_INF, NULL); if(ret < 0) { fprintf(stderr, "job_bmi_recv() failure.\n"); return(-1); } if(ret == 0) { int count = 0; ret = job_test(tmp_id, &count, NULL, &status1, -1, context); if(ret < 0) { fprintf(stderr, "job_test() failure.\n"); return(-1); } } /* check status */ if(status1.error_code != 0) { fprintf(stderr, "job failure.\n"); return(-1); } /* check the size */ if(status1.actual_size != sizeof(struct ack_foo)) { fprintf(stderr, "short recv.\n"); return(-1); } /* free memory buffers */ BMI_memfree(server_addr, req, sizeof(struct request_foo), BMI_SEND); BMI_memfree(server_addr, ack, sizeof(struct ack_foo), BMI_RECV); /* shut down the interfaces */ job_close_context(context); job_finalize(); BMI_finalize(); trove_finalize(TROVE_METHOD_DBPF); return(0); }
int main(int argc, char **argv) { int ret = -1; struct ack_foo* ack = NULL; job_status_s status1; struct BMI_unexpected_info req_info; job_id_t job_id; int outcount; job_id_t tmp_id; job_context_id context; /* set debugging level */ gossip_enable_stderr(); gossip_set_debug_mask(0, 0); /* start the BMI interface */ ret = BMI_initialize("bmi_tcp", "tcp://NULL:3414", BMI_INIT_SERVER); if(ret < 0) { fprintf(stderr, "BMI_initialize failure.\n"); return(-1); } ret = trove_initialize( TROVE_METHOD_DBPF, NULL, "/tmp/pvfs2-test-space", 0); if(ret < 0) { fprintf(stderr, "trove_initialize failure.\n"); return(-1); } /* start the flow interface */ ret = PINT_flow_initialize("flowproto_multiqueue", 0); if(ret < 0) { fprintf(stderr, "flow_init failure.\n"); return(-1); } /* start the job interface */ ret = job_initialize(0); if(ret < 0) { fprintf(stderr, "job_initialize failure.\n"); return(-1); } ret = job_open_context(&context); if(ret < 0) { fprintf(stderr, "job_open_context() failure.\n"); return(-1); } /* post a job for unexpected receive */ ret = job_bmi_unexp(&req_info, NULL, 0, &status1, &job_id, 0, context); if(ret < 0) { fprintf(stderr, "job_bmi_unexp() failure.\n"); return(-1); } if(ret != 1) { #if 0 /* exercise testworld() interface, block indefinitely */ outcount = 1; ret = job_testworld(&job_id, &outcount, NULL, &status1, -1); if(ret < 0 || outcount == 0) { fprintf(stderr, "job_testworld() failure.\n"); return(-1); } /* alternatively, try out the testsome interface */ outcount = 1; ret = job_testsome(&job_id, &outcount, &foo, NULL, &status1, -1); if(ret < 0 || outcount == 0) { fprintf(stderr, "job_testsome() failure.\n"); return(-1); } #else /* ... or maybe even give job_test() a whirl */ ret = job_test(job_id, &outcount, NULL, &status1, 5000, context); if(ret < 0 || outcount == 0) { fprintf(stderr, "job_test() failure.\n"); return(-1); } #endif } /* check status */ if(status1.error_code != 0) { fprintf(stderr, "Bad status in unexp recv.\n"); return(-1); } /* allocate a buffer for the ack */ ack = BMI_memalloc(req_info.addr, sizeof(struct ack_foo), BMI_SEND); if(!ack) { fprintf(stderr, "BMI_memalloc failure.\n"); return(-1); } /* send a message */ ret = job_bmi_send(req_info.addr, ack, sizeof(struct ack_foo), 0, BMI_PRE_ALLOC, 0, NULL, 0, &status1, &tmp_id, context, JOB_TIMEOUT_INF, NULL); if(ret < 0) { fprintf(stderr, "job_bmi_send() failure.\n"); return(-1); } if(ret == 0) { int count = 0; ret = job_test(tmp_id, &count, NULL, &status1, -1, context); if(ret < 0) { fprintf(stderr, "job_test() failure.\n"); return(-1); } } /* check status */ if(status1.error_code != 0) { fprintf(stderr, "job failure.\n"); return(-1); } BMI_memfree(req_info.addr, ack, sizeof(struct ack_foo), BMI_RECV); BMI_unexpected_free(req_info.addr, req_info.buffer); /* shut down the interfaces */ job_close_context(context); job_finalize(); PINT_flow_finalize(); BMI_finalize(); trove_finalize(TROVE_METHOD_DBPF); return(0); }