{"action":"created","issue":{"url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic/issues/357","repository_url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic","labels_url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic/issues/357/labels{/name}","comments_url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic/issues/357/comments","events_url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic/issues/357/events","html_url":"https://github.com/mpiforumbot/mpi-forum-historic/issues/357","id":167250086,"number":357,"title":"thread-safety of MPI_INITIALIZED, MPI_FINALIZED, MPI_QUERY_THREAD and MPI_IS_THREAD_MAIN in all uses for library correctness","user":{"login":"mpiforumbot","id":20617676,"avatar_url":"https://avatars.githubusercontent.com/u/20617676?v=3","gravatar_id":"","url":"https://api.github.com/users/mpiforumbot","html_url":"https://github.com/mpiforumbot","followers_url":"https://api.github.com/users/mpiforumbot/followers","following_url":"https://api.github.com/users/mpiforumbot/following{/other_user}","gists_url":"https://api.github.com/users/mpiforumbot/gists{/gist_id}","starred_url":"https://api.github.com/users/mpiforumbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpiforumbot/subscriptions","organizations_url":"https://api.github.com/users/mpiforumbot/orgs","repos_url":"https://api.github.com/users/mpiforumbot/repos","events_url":"https://api.github.com/users/mpiforumbot/events{/privacy}","received_events_url":"https://api.github.com/users/mpiforumbot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic/labels/MPI%20%3Cnext%3E","name":"MPI <next>","color":"d4c5f9"},{"url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic/labels/Text%20committed","name":"Text committed","color":"d93f0b"},{"url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic/labels/Text%20%5C(only%5C)%20changes","name":"Text \\(only\\) changes","color":"ededed"},{"url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic/labels/Ticket%20complete","name":"Ticket complete","color":"bfdadc"}],"state":"open","locked":false,"assignee":{"login":"mpiforumbot","id":20617676,"avatar_url":"https://avatars.githubusercontent.com/u/20617676?v=3","gravatar_id":"","url":"https://api.github.com/users/mpiforumbot","html_url":"https://github.com/mpiforumbot","followers_url":"https://api.github.com/users/mpiforumbot/followers","following_url":"https://api.github.com/users/mpiforumbot/following{/other_user}","gists_url":"https://api.github.com/users/mpiforumbot/gists{/gist_id}","starred_url":"https://api.github.com/users/mpiforumbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpiforumbot/subscriptions","organizations_url":"https://api.github.com/users/mpiforumbot/orgs","repos_url":"https://api.github.com/users/mpiforumbot/repos","events_url":"https://api.github.com/users/mpiforumbot/events{/privacy}","received_events_url":"https://api.github.com/users/mpiforumbot/received_events","type":"User","site_admin":false},"assignees":[{"login":"mpiforumbot","id":20617676,"avatar_url":"https://avatars.githubusercontent.com/u/20617676?v=3","gravatar_id":"","url":"https://api.github.com/users/mpiforumbot","html_url":"https://github.com/mpiforumbot","followers_url":"https://api.github.com/users/mpiforumbot/followers","following_url":"https://api.github.com/users/mpiforumbot/following{/other_user}","gists_url":"https://api.github.com/users/mpiforumbot/gists{/gist_id}","starred_url":"https://api.github.com/users/mpiforumbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpiforumbot/subscriptions","organizations_url":"https://api.github.com/users/mpiforumbot/orgs","repos_url":"https://api.github.com/users/mpiforumbot/repos","events_url":"https://api.github.com/users/mpiforumbot/events{/privacy}","received_events_url":"https://api.github.com/users/mpiforumbot/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic/milestones/30","html_url":"https://github.com/mpiforumbot/mpi-forum-historic/milestones/2013/03/11%20Chicago,%20USA","labels_url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic/milestones/30/labels","id":1900491,"number":30,"title":"2013/03/11 Chicago, USA","description":"","creator":{"login":"mpiforumbot","id":20617676,"avatar_url":"https://avatars.githubusercontent.com/u/20617676?v=3","gravatar_id":"","url":"https://api.github.com/users/mpiforumbot","html_url":"https://github.com/mpiforumbot","followers_url":"https://api.github.com/users/mpiforumbot/followers","following_url":"https://api.github.com/users/mpiforumbot/following{/other_user}","gists_url":"https://api.github.com/users/mpiforumbot/gists{/gist_id}","starred_url":"https://api.github.com/users/mpiforumbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpiforumbot/subscriptions","organizations_url":"https://api.github.com/users/mpiforumbot/orgs","repos_url":"https://api.github.com/users/mpiforumbot/repos","events_url":"https://api.github.com/users/mpiforumbot/events{/privacy}","received_events_url":"https://api.github.com/users/mpiforumbot/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":8,"state":"closed","created_at":"2016-07-23T22:09:13Z","updated_at":"2016-07-24T19:38:22Z","due_on":"2013-03-14T04:00:00Z","closed_at":"2016-07-23T22:09:13Z"},"comments":2,"created_at":"2016-07-24T19:38:21Z","updated_at":"2016-07-24T19:38:25Z","closed_at":null,"body":"**Originally by _jhammond_ on 2012-12-27 13:42:57 -0600**\n\n___\nIf there is a library that requires MPI support a thread level besides `MPI_THREAD_SINGLE`, it should query what is available, possibly in the following manner.\n```\n#include <stdio.h>\n#include <mpi.h>\n\nvoid my_error_handler(void);\n\n#define MPI_THREAD_STRING(level)  \\\n        ( level==MPI_THREAD_SERIALIZED ? \"THREAD_SERIALIZED\" : \\\n            ( level==MPI_THREAD_MULTIPLE ? \"THREAD_MULTIPLE\" : \\\n                ( level==MPI_THREAD_FUNNELED ? \"THREAD_FUNNELED\" : \\\n                    ( level==MPI_THREAD_SINGLE ? \"THREAD_SINGLE\" : \"WTF\" ) ) ) )\n\n/* This function determines if and how my library can use MPI from threads. */\nint this_thread_can_make_mpi_calls(void)\n{\n  int rc;\n  int is_init;\n  int provided;\n  int is_main;\n  rc = MPI_Initialized(&is_init);\n  if (rc!=MPI_SUCCESS) my_error_handler();\n  if (is_init)\n  {\n    rc = MPI_Query_thread(&provided);\n    if (rc!=MPI_SUCCESS) my_error_handler();\n\n    if (provided==MPI_THREAD_SERIALIZED || \n        provided==MPI_THREAD_MULTIPLE)\n    {\n      return 1;\n    }\n    else if (provided==MPI_THREAD_FUNNELED)\n    {\n      rc = MPI_Is_thread_main(&is_main);\n      if (rc!=MPI_SUCCESS) my_error_handler();\n      return is_main;\n    }\n    else\n    {\n      return 0;\n    }\n  }\n  else\n  {\n    return -1;\n  }\n}\n```\n\n(This code is only illustrative, so I ignore the issue of serialization required in the case of `MPI_THREAD_SERIALIZED`.)\n\nIn order for this function to work in general, i.e. be callable from threads by a library that would like to be able to make MPI calls from threads, then each of `MPI_INITIALIZED`, `MPI_QUERY_THREAD`, and `MPI_IS_THREAD_MAIN` needs to be fully thread-safe (in the sense of `MPI_THREAD_MULTIPLE`), irrespective of the level of thread support available to other MPI functionality.\n\nThe text change required is the addition of something similar to the following for each of the three aforementioned functions.\n```\nThis function is callable from threads without restriction (in the sense of \nMPI_THREAD_MULTIPLE), irrespective of the actual level of thread support \nprovided, in the case where the implementation supports threads.  \nImplementations that do not support threads are not required to support \nthe calling of these functions from threads.\n```\nI assume that the relevant chapter committee or committees have a better wording."},"comment":{"url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic/issues/comments/234797448","html_url":"https://github.com/mpiforumbot/mpi-forum-historic/issues/357#issuecomment-234797448","issue_url":"https://api.github.com/repos/mpiforumbot/mpi-forum-historic/issues/357","id":234797448,"user":{"login":"mpiforumbot","id":20617676,"avatar_url":"https://avatars.githubusercontent.com/u/20617676?v=3","gravatar_id":"","url":"https://api.github.com/users/mpiforumbot","html_url":"https://github.com/mpiforumbot","followers_url":"https://api.github.com/users/mpiforumbot/followers","following_url":"https://api.github.com/users/mpiforumbot/following{/other_user}","gists_url":"https://api.github.com/users/mpiforumbot/gists{/gist_id}","starred_url":"https://api.github.com/users/mpiforumbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpiforumbot/subscriptions","organizations_url":"https://api.github.com/users/mpiforumbot/orgs","repos_url":"https://api.github.com/users/mpiforumbot/repos","events_url":"https://api.github.com/users/mpiforumbot/events{/privacy}","received_events_url":"https://api.github.com/users/mpiforumbot/received_events","type":"User","site_admin":false},"created_at":"2016-07-24T19:38:25Z","updated_at":"2016-07-24T19:38:25Z","body":"**Originally by _jsquyres_ on 2013-03-12 14:41:20 -0500**\n\n___\nTo be pedantic, I think you need MPI_FINALIZED in this list, too."}}
{"actor":{"display_login":"mpiforumbot"}}