{"action":"opened","issue":{"url":"https://api.github.com/repos/ComputationalRadiationPhysics/cupla/issues/28","repository_url":"https://api.github.com/repos/ComputationalRadiationPhysics/cupla","labels_url":"https://api.github.com/repos/ComputationalRadiationPhysics/cupla/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/ComputationalRadiationPhysics/cupla/issues/28/comments","events_url":"https://api.github.com/repos/ComputationalRadiationPhysics/cupla/issues/28/events","html_url":"https://github.com/ComputationalRadiationPhysics/cupla/issues/28","id":137749741,"number":28,"title":"support for math_functions.h","user":{"login":"mxmlnkn","id":6842824,"avatar_url":"https://avatars.githubusercontent.com/u/6842824?v=3","gravatar_id":"","url":"https://api.github.com/users/mxmlnkn","html_url":"https://github.com/mxmlnkn","followers_url":"https://api.github.com/users/mxmlnkn/followers","following_url":"https://api.github.com/users/mxmlnkn/following{/other_user}","gists_url":"https://api.github.com/users/mxmlnkn/gists{/gist_id}","starred_url":"https://api.github.com/users/mxmlnkn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mxmlnkn/subscriptions","organizations_url":"https://api.github.com/users/mxmlnkn/orgs","repos_url":"https://api.github.com/users/mxmlnkn/repos","events_url":"https://api.github.com/users/mxmlnkn/events{/privacy}","received_events_url":"https://api.github.com/users/mxmlnkn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-02T02:08:59Z","updated_at":"2016-03-02T02:08:59Z","closed_at":null,"body":"I got the following when porting by search and replace from CUDA to cupla:\r\n\r\n    error: there are no arguments to ‘max’ that depend on a template parameter, so a declaration of ‘max’ must be available\r\n\r\ncupla should provide such a function (also simple min was missing). CUDA provides this in `math_functions.h` which is included by `common_functions.h` which is included by `cuda_runtime.h`. I didn't include this manually, but I guess `nvcc` did include this for me just like it is unnecessary to write `#include <cuda.h>` in a `.cu` file.\r\n\r\nI guess min and max are not the only missing functions, henceforth the title.\r\n\r\nThe problem is, that `std::max` and so on can't be called from a device function.\r\n\r\nCurrent workaround:\r\n\r\n    #ifndef max\r\n    #   define max( a, b ) ( ((a) > (b)) ? (a) : (b) )\r\n    #endif\r\n    #ifndef min\r\n    #   define min( a, b ) ( ((a) < (b)) ? (a) : (b) )\r\n    #endif\r\n"}}