Altera_Forum
Honored Contributor
9 years agoMPI + OpenCL Altera
Hi everybody,
I am a master's student, I study at University of São Paulo (USP) - Brazil. Here we have an Stratix V development kit from Bittware (model s5phq_a7). I'm using OpenCL for a research project, project is a co-design of a legacy software. The board with a custom platform, so I don't to create one and all the communication is done through PCIe. The software uses MPI, which has causing me trouble with Altera OpenCL. OpenCL demands to create five structures for properly working (context, program, device, kernel and queue). If I have only one process doing all the job, I have no problem during execution. But if I try to start more than one process a serious problem happens, the entire system freezes because the two (or more) process are trying to send AOCX to the same board (I have only one board, and I need to use more than one process per board). I already tried to create program structure only once (only the master creating it), and the slaves to use it, but when I do it, the slaves get segmentation fault because program structure was not created. This happens when I set program structure, this structure is responsible to reconfigure the board through AOCX file. I would like to know if it's possible to create this structure only once and use for all process, or if OpenCL Altera allows me query the hardware reconfigured on the board and get a pointer to it. I know MPI does not allow to share variables or structures between processes. So share program structure is impossible. Bellow It's part of my source code to show how I'm declaring theses structures: bool init_opencl(int *n, boll *success){ cl_int status; int ARRAY_SIZE = *n; int nnz = ((ARRAY_SIZE*(ARRAY_SIZE-1)-1)/2); *success = false; if(!setCwdToExeDir()) { *success = false; return false; } platform = findPlatform("Intel(R) FPGA SDK for OpenCL(TM)"); if(platform == NULL) { printf("ERROR: Unable to find Intel(R) FPGA OpenCL platform.\n"); *success = false; return false; } device.reset(getDevices(platform, CL_DEVICE_TYPE_ALL, &num_devices)); context = clCreateContext(NULL, num_devices, device, &oclContextCallback, NULL, &status); checkError(status, "Failed to create context"); std::string binary_file = getBoardBinaryFile(PROGRAM_FILE, device[0]); if(*id_process == 0){ // I tried to make only master to create the program structure program = createProgramFromBinary(context, binary_file.c_str(), device, num_devices); } status = clBuildProgram(program, 0, NULL, "", NULL, NULL); checkError(status, "Failed to build program"); kernel.reset(1); kernel[0] = clCreateKernel(program, KERNEL_FUNC, &status); checkError(status, "Failed to create kernel"); ... } I hope I had been clear about my problem.:) Carlos.