Better alternating between video cards
| | |
| | | #include <stdio.h> |
| | | #include <stdlib.h> |
| | | #include <string.h> |
| | | #include <time.h> |
| | | #include <unistd.h> |
| | | |
| | | |
| | | cl_info cl = {0}; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | #define MAX_DEVICES 10 |
| | | |
| | | cl_info cl_init() |
| | | { |
| | | cl_info info; |
| | | info.initialized = 0; |
| | | //cl_uint num_platforms, num_devices; |
| | | cl_uint num_platforms, num_devices; |
| | | // Fetch the Platform and Device IDs; we only want one. |
| | | cl_device_id devices[2]; |
| | | info.error=clGetPlatformIDs(1, &info.platform, 0); |
| | | cl_device_id devices[MAX_DEVICES]; |
| | | info.error=clGetPlatformIDs(1, &info.platform, &num_platforms); |
| | | check_error(info); |
| | | info.error=clGetDeviceIDs(info.platform, CL_DEVICE_TYPE_ALL, 2, devices, 0); |
| | | info.device = devices[rand()%2]; |
| | | info.error=clGetDeviceIDs(info.platform, CL_DEVICE_TYPE_ALL, MAX_DEVICES, devices, &num_devices); |
| | | if(num_devices > MAX_DEVICES) num_devices = MAX_DEVICES; |
| | | int index = getpid()%num_devices; |
| | | printf("%d rand, %d devices, %d index\n", getpid(), num_devices, index); |
| | | info.device = devices[index]; |
| | | fprintf(stderr, "Found %d device(s)\n", num_devices); |
| | | check_error(info); |
| | | |
| | | cl_context_properties properties[]={ |
| | |
| | | if (flip)sprintf(out_path, "%s%d/%s_r.txt",out_dir, interval, image_file); |
| | | else sprintf(out_path, "%s%d/%s.txt",out_dir, interval, image_file); |
| | | printf("%s\n", image_file); |
| | | FILE *fp = fopen(out_path, "w"); |
| | | if(fp == 0) file_error(out_path); |
| | | |
| | | IplImage* src = 0; |
| | | if( (src = cvLoadImage(image_path,-1)) == 0 ) file_error(image_path); |
| | |
| | | ims[j+interval] = features_output_size(net, src, ex_h, ex_w); |
| | | } |
| | | } |
| | | FILE *fp = fopen(out_path, "w"); |
| | | if(fp == 0) file_error(out_path); |
| | | for(i = 0; i < max_scale+interval; ++i){ |
| | | image out = ims[i]; |
| | | fprintf(fp, "%d, %d, %d\n",out.c, out.h, out.w); |