|  | 
| 86 | 86 | 
 | 
| 87 | 87 | #define OPAL_BTL_USNIC_NUM_COMPLETIONS 500 | 
| 88 | 88 | 
 | 
|  | 89 | +/* MPI_THREAD_MULTIPLE_SUPPORT */ | 
|  | 90 | +opal_recursive_mutex_t btl_usnic_lock; | 
|  | 91 | + | 
| 89 | 92 | /* RNG buffer definition */ | 
| 90 | 93 | opal_rng_buff_t opal_btl_usnic_rand_buff = {0}; | 
| 91 | 94 | 
 | 
| @@ -222,6 +225,8 @@ static int usnic_component_close(void) | 
| 222 | 225 |     opal_btl_usnic_cleanup_tests(); | 
| 223 | 226 | #endif | 
| 224 | 227 | 
 | 
|  | 228 | +    OBJ_DESTRUCT(&btl_usnic_lock); | 
|  | 229 | + | 
| 225 | 230 |     return OPAL_SUCCESS; | 
| 226 | 231 | } | 
| 227 | 232 | 
 | 
| @@ -615,13 +620,22 @@ static mca_btl_base_module_t** usnic_component_init(int* num_btl_modules, | 
| 615 | 620 | 
 | 
| 616 | 621 |     *num_btl_modules = 0; | 
| 617 | 622 | 
 | 
| 618 |  | -    /* Currently refuse to run if MPI_THREAD_MULTIPLE is enabled */ | 
|  | 623 | +    /* MPI_THREAD_MULTIPLE is only supported in 2.0+ */ | 
| 619 | 624 |     if (want_mpi_threads && !mca_btl_base_thread_multiple_override) { | 
| 620 |  | -        opal_output_verbose(5, USNIC_OUT, | 
| 621 |  | -                            "btl:usnic: MPI_THREAD_MULTIPLE not supported; skipping this component"); | 
| 622 |  | -        return NULL; | 
|  | 625 | + | 
|  | 626 | +	if (OMPI_MAJOR_VERSION >= 2) { | 
|  | 627 | +            opal_output_verbose(5, USNIC_OUT, | 
|  | 628 | +                                "btl:usnic: MPI_THREAD_MULTIPLE support is in testing phase."); | 
|  | 629 | +	} | 
|  | 630 | +	else { | 
|  | 631 | +            opal_output_verbose(5, USNIC_OUT, | 
|  | 632 | +                                "btl:usnic: MPI_THREAD_MULTIPLE is not supported in version < 2."); | 
|  | 633 | +	    return NULL; | 
|  | 634 | +	} | 
| 623 | 635 |     } | 
| 624 | 636 | 
 | 
|  | 637 | +    OBJ_CONSTRUCT(&btl_usnic_lock, opal_recursive_mutex_t); | 
|  | 638 | + | 
| 625 | 639 |     /* We only want providers named "usnic that are of type EP_DGRAM */ | 
| 626 | 640 |     fabric_attr.prov_name = "usnic"; | 
| 627 | 641 |     ep_attr.type = FI_EP_DGRAM; | 
| @@ -1151,6 +1165,8 @@ static int usnic_handle_completion( | 
| 1151 | 1165 |     /* Make the completion be Valgrind-defined */ | 
| 1152 | 1166 |     opal_memchecker_base_mem_defined(seg, sizeof(*seg)); | 
| 1153 | 1167 | 
 | 
|  | 1168 | +    OPAL_THREAD_LOCK(&btl_usnic_lock); | 
|  | 1169 | + | 
| 1154 | 1170 |     /* Handle work completions */ | 
| 1155 | 1171 |     switch(seg->us_type) { | 
| 1156 | 1172 | 
 | 
| @@ -1181,6 +1197,8 @@ static int usnic_handle_completion( | 
| 1181 | 1197 |         BTL_ERROR(("Unhandled completion segment type %d", seg->us_type)); | 
| 1182 | 1198 |         break; | 
| 1183 | 1199 |     } | 
|  | 1200 | + | 
|  | 1201 | +    OPAL_THREAD_UNLOCK(&btl_usnic_lock); | 
| 1184 | 1202 |     return 1; | 
| 1185 | 1203 | } | 
| 1186 | 1204 | 
 | 
|  | 
0 commit comments